3 回答
TA贡献1786条经验 获得超11个赞
对于遇到此问题的其他任何人,由于我npm将其安装到不在我的位置上而遇到了这个问题NODE_PATH。
[root@uberneek ~]# which npm
/opt/bin/npm
[root@uberneek ~]# which node
/opt/bin/node
[root@uberneek ~]# echo $NODE_PATH
我的NODE_PATH为空,运行npm install --global --verbose promised-io显示它正在安装到中/opt/lib/node_modules/promised-io:
[root@uberneek ~]# npm install --global --verbose promised-io
npm info it worked if it ends with ok
npm verb cli [ '/opt/bin/node',
npm verb cli '/opt/bin/npm',
npm verb cli 'install',
npm verb cli '--global',
npm verb cli '--verbose',
npm verb cli 'promised-io' ]
npm info using npm@1.1.45
npm info using node@v0.8.4
[cut]
npm info build /opt/lib/node_modules/promised-io
npm verb from cache /opt/lib/node_modules/promised-io/package.json
npm verb linkStuff [ true, '/opt/lib/node_modules', true, '/opt/lib/node_modules' ]
[cut]
我的脚本失败require('promised-io/promise'):
[neek@uberneek project]$ node buildscripts/stringsmerge.js
module.js:340
throw err;
^
Error: Cannot find module 'promised-io/promise'
at Function.Module._resolveFilename (module.js:338:15)
我可能使用的源安装了node和npm configure --prefix=/opt。我不知道为什么这使他们无法找到已安装的模块。现在的解决方法是将NODE_PATH指向正确的目录:
export NODE_PATH=/opt/lib/node_modules
我require('promised-io/promise')现在成功了。
- 3 回答
- 0 关注
- 2437 浏览
添加回答
举报