【发布时间】:2015-06-26 23:13:28
【问题描述】:
在使用npm 安装软件包时,我最近遇到了一个问题,即弹出Node 找不到模块/脚本的错误。出于某种原因,它在我的C:/ 目录中查找,而不是C:/my-project/node_modules。尤其是这个库一直很麻烦,但我以前也看到过这种情况。
我正在运行 Win7 x32,v0.10.35 为 Node。
这是我尝试安装 node-sass 时看到的示例:
C:\node\test>npm install node-sass
> node-sass@2.0.0-beta install C:\node\test\node_modules\node-sass
> node scripts/install.js
module.js:340
throw err;
^
Error: Cannot find module 'C:\scripts\install.js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:929:3
npm ERR! node-sass@2.0.0-beta install: `node scripts/install.js`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the node-sass@2.0.0-beta install script.
npm ERR! This is most likely a problem with the node-sass package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node scripts/install.js
npm ERR! You can get their info via:
npm ERR! npm owner ls node-sass
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "node-sass"
npm ERR! cwd C:\node\test
npm ERR! node -v v0.10.35
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0
一位同事给我发了他的install.js 文件,我把它放在我的根目录下,看看会发生什么。不幸的是,一旦npm 尝试安装根模块所需的模块,安装仍然失败。
【问题讨论】:
-
您有
.npmrc文件吗?如果有,请提供:) -
@AlexFord 我以前没有听说过
.npmrc文件,只是开始查看它们。谢谢你的提示!哪一个最有价值? -
如果你没有,那么它是不相关的。它只是 NPM 的配置文件。不过,我对 Windows 上的节点不再那么熟悉了:/
标签: node.js filesystems npm node-modules