使用NPM安装时未找到Express模块 [英] Express module not found when installed with NPM
问题描述
当我尝试运行由express创建的app.js文件时,我收到以下错误:
When I try to run the app.js file created by express, I get the following error:
$ node app.js
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'express'
at Function._resolveFilename (module.js:320:11)
当我输入'express --version'时,我得到一个2.3.3的返回语句。我用npm安装快递。我不得不使用这些说明手动做npm:
When I type in 'express --version' I get a return statement of 2.3.3. I used npm to install express. I had to manually make npm using these instructions:
git clone http://github.com/isaacs/npm.git
cd npm
sudo make install
错误是错误:找不到模块'express'
。
安装npm和express后,我需要做些什么才能快速查看模块由npm创建?
Do I need to do something after installing npm and express in order to make express see the modules created by npm?
我的节点是版本:0.4.6
我的快照是版本:2.3.3
我的npm是版本:1.0。 6
My node is version: 0.4.6 My express is version: 2.3.3 My npm is version: 1.0.6
Express全球安装。我使用-g标志来安装它。
Express is installed globally. I used the -g flag to install it.
编辑:当我尝试node -e require.paths时,我得到:
When I try "node -e require.paths" I get:
['/home/user/.node_modules',
'/home/user/.node_libraries',
'/ usr / local / lib / node']
[ '/home/user/.node_modules', '/home/user/.node_libraries', '/usr/local/lib/node' ]
所以,节点没有检测到npm的安装。如何让节点检测到npm安装?
So, node isn't detecting the npm installation. How do I get node to detect the npm installation?
推荐答案
我有同样的问题。这对我来说很有效:
I had the same problem. This worked for me though:
看起来像npm(现在?)将节点模块安装到 / usr / local / lib / node_modules /
而不是 / usr / local / lib / node /
Seems like npm (now?) installs node modules to /usr/local/lib/node_modules/
and not /usr/local/lib/node/
我做的只是复制从node_modules到节点的所有内容: sudo cp -r / usr / local / lib / node_modules / * usr / local / lib / node /
现在似乎在为我工作。
What I did was simply to copy everything from node_modules to node: sudo cp -r /usr/local/lib/node_modules/* usr/local/lib/node/
and now it seems to be working for me.
希望这有助于您: - )
Hope this helps you :-)
这篇关于使用NPM安装时未找到Express模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!