我正在使用 nodejs 和 npm 开发应用程序。我有 Windows 10,我正在使用 npm v.3.3.7 和节点 v.4.1.2。
要设置它们,我将执行以下步骤:
- 使用 npm 安装 NodeJ
- 从 git 下载 Npm-master 3.3.7 并覆盖文件夹 C:\Program Files\nodejs\node_modules\npm
- 添加在环境变量 C:\Users\bilias7\AppData\Roaming\npm;C:\Program Files\nodejs; 对于当前用户和系统 PATH 变量。
直到这里一切正常,我可以从 CMD 使用 node 和 npm,并且使用提升的 CMD 我可以安装全局包。
当我尝试安装依赖于 node-sass 的 gulp-sass 时,问题就开始了。下面的命令返回一个错误,即节点未被识别为内部或外部命令。
npm install -g gulp-sass
正如您在下面的错误中看到的那样,安装 node-sass 包返回的错误。
'node' is not recognized as an internal or external command,
operable program or batch file.
npm WARN install:node-sass@3.3.3 node-sass@3.3.3 install: `node scripts/install.js`
npm WARN install:node-sass@3.3.3 Exit status 1
C:\Program Files\nodejs
└── (empty)
npm ERR! code 1
所以我尝试使用以下命令显式安装 node-sass
npm install -g node-sass
我得到了如下的详细错误。我想 install.js 执行内部出了点问题,它没有与命令节点连接,但我不知道那是什么。
C:\Program Files\nodejs\node-sass -> C:\Program Files\nodejs\node_modules\node-sass\bin\node-sass
> node-sass@3.3.3 install C:\Program Files\nodejs\node_modules\node-sass
> node scripts/install.js
'node' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! Windows_NT 10.0.10240
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "node-sass"
npm ERR! node v4.1.2
npm ERR! npm v3.3.7
npm ERR! code ELIFECYCLE
npm ERR! node-sass@3.3.3 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@3.3.3 install script 'node scripts/install.js'.
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! Please include the following file with any support request:
npm ERR! C:\Windows\system32\npm-debug.log
您也可以从这里下载完整的日志文件
任何想法都是有帮助和受欢迎的,因为我已经花了 20 多个小时了!!