从GitHub下拉模块并按照说明构建它之后,我尝试使用以下方法将其拉入现有项目中:
> npm install ../faye
Run Code Online (Sandbox Code Playgroud)
这似乎可以解决问题:
> npm list
/home/dave/src/server
??? faye@0.7.1
??? cookiejar@1.3.0
??? hiredis@0.1.13
??? redis@0.7.1
Run Code Online (Sandbox Code Playgroud)
但是Node.js找不到模块:
> node app.js
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'faye'
at Function._resolveFilename (module.js:334:11)
at Function._load (module.js:279:25)
at Module.require (module.js:357:17)
at require (module.js:368:17)
at Object.<anonymous> (/home/dave/src/server/app.js:2:12)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Array.0 (module.js:470:10)
Run Code Online (Sandbox Code Playgroud)
我真的很想了解这里发生了什么,但我对于下一步该看哪里感到有点失落.有什么建议?
我正在尝试全局安装,然后使用forever并forever-monitor像这样:
npm install -g forever forever-monitor
我看到了通常的输出以及将文件复制到全局路径的操作,但是如果我尝试require("forever");得到错误,说明找不到该模块.
我正在使用node和npm的最新版本,我已经知道npm在全局和本地安装中所做的更改,但我真的不想在每个项目上安装localy而且我正在开发一个平台"科技支撑link这么npm link之后全球安装是不可能的我.
我的问题是:为什么我不能要求全局安装包?这是一个功能还是一个bug?或者我做错了什么?
PS:只是为了说清楚:我不想在本地安装.
我写了我的第一个node.js应用程序,但它找不到快递库:
C:\ChatServer\Server>node server.js
module.js:340
throw err;
^
Error: Cannot find module 'express'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (C:\ChatServer\Server\server.js:6:9)
at Object.<anonymous> (C:\ChatServer\Server\server.js:25:4)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
Run Code Online (Sandbox Code Playgroud)
但快递被挂了(带-g钥匙):
C:\ChatServer\Server>npm install -g express
npm http GET https://registry.npmjs.org/express
npm http 304 https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/connect/2.7.11
npm http GET https://registry.npmjs.org/commander/0.6.1
npm http GET https://registry.npmjs.org/range-parser/0.0.4
npm http GET https://registry.npmjs.org/mkdirp/0.3.4
npm http GET https://registry.npmjs.org/cookie/0.1.0
npm http GET …Run Code Online (Sandbox Code Playgroud) 这是我在ubuntu 14.04 LTS中安装nodejs的方式:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get install nodejs
Run Code Online (Sandbox Code Playgroud)
当我用这个检查节点版本时:
node -v
Run Code Online (Sandbox Code Playgroud)
我明白了
v0.10.37
Run Code Online (Sandbox Code Playgroud)
但最新版本是4.2.6和5.5.0.我如何获得最新版本或更新版本?
我想在Ubuntu 12.04上安装NodeJS版本0.8.18.我尝试安装最新版本,然后通过使用恢复到0.8.18 nvm,但是当我运行我的代码时,显然安装的软件包和两个版本(最新版本和0.8.18)存在一些问题.由于我不知道如何解决这个问题,我从Node安装中清理了机器,并考虑直接安装我感兴趣的版本(v0.8.18).
在开发过程中我习惯了WebStorm node_path =.环境变量.我在项目设置的启动中设置了一个变量.现在我想尝试在服务器上运行该项目,但不知道如何在那里设置这个变量.帮助解决问题!