无法安装 gulp-sass

Cannot Install gulp-sass

我正在尝试学习如何使用 gulp / sass / 以及所有其他有趣的 Nodejs 工具,但我在安装 gulp-sass。我用来安装所有东西的过程是:

1.  Start Git Bash in the project folder
2.  npm init
3.  npm install gulp -g
4.  npm install gulp --save-dev
5.  npm install gulp-sass <- this is where I get errors

进行到第五步后,出现以下错误:

$ npm install gulp-sass
npm WARN package.json project@1.0.0 No repository field.
npm WARN package.json project@1.0.0 No README data
-
> node-sass@3.2.0 install     \primary\home\mendsley\profile\Desktop\project\node_modules\gulp-  sass\node_modules\node-sass
> node scripts/install.js

'\primary\home\mendsley\profile\Desktop\project\node_modules\gulp-   sass\node_modules\node-sass'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
module.js:338
throw err;
      ^
Error: Cannot find module 'C:\Windows\scripts\install.js'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "c:\Program Files\nodejs\node.exe"     "c:\Users\mendsley\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js"     "install" "gulp-sass"
npm ERR! node v0.12.1
npm ERR! npm  v2.13.1
npm ERR! code ELIFECYCLE

npm ERR! node-sass@3.2.0 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@3.2.0 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!     \primary\home\mendsley\profile\Desktop\project\npm-debug.log

我正在我的工作计算机上尝试这个,所以我不确定这是否重要。系统管理员说应该没有任何问题,其他人对同一个包裹也没有问题……与他们交谈,他们没有提供任何帮助。我在我的个人笔记本电脑上尝试了一切,gulp-sass 安装得很好,所以它适合我的工作电脑。

我最初的想法是这是一个路径问题,但为什么其他包安装没问题?

我用了 uninstall/reinstall Nodejs,但没有用。

有人知道吗?

提前致谢!

您的第一个猜测是正确的,因为这是路径名的问题。来自错误消息:

UNC paths are not supported. Defaulting to Windows directory.

Npm 需要访问 \primary\home\mendsley\...\node_modules\node-sass 才能执行 gulp-sass 安装脚本。但此路径是 UNC 路径(统一命名约定),因此不受支持。

因此,npm 命令默认为 C:/Windows,并尝试执行 gulp-[=26 的安装脚本=] (install.js) 但正如您可能猜到的那样,此脚本不存在于此目录中。

它也可能是旧 NodeJS 或 NPM 版本的 依赖地狱 问题。 gulp-sass 依赖于 node-sass,后者又依赖于其他包,它们还依赖于正确的 NodeJS 和 NPM 版本。对于版本 0.7.3,完整的依赖项如下所示:

├─┬ gulp-sass@0.7.3 │ ├── map-stream@0.1.0 │ └─┬ node-sass@0.9.6 │ ├─┬ chalk@0.5.1 │ │ ├── ansi-styles@1.1.0 │ │ ├── escape-string-regexp@1.0.3 │ │ ├─┬ has-ansi@0.1.0 │ │ │ └── ansi-regex@0.2.1 │ │ ├─┬ strip-ansi@0.3.0 │ │ │ └── ansi-regex@0.2.1 │ │ └── supports-color@0.2.0 │ ├── get-stdin@3.0.2 │ ├─┬ mkdirp@0.5.1 │ │ └── minimist@0.0.8 │ ├─┬ mocha@1.21.5 │ │ ├── commander@2.3.0 │ │ ├─┬ debug@2.0.0 │ │ │ └── ms@0.6.2 │ │ ├── diff@1.0.8 │ │ ├── escape-string-regexp@1.0.2 │ │ ├─┬ glob@3.2.3 │ │ │ ├── graceful-fs@2.0.3 │ │ │ ├── inherits@2.0.1 │ │ │ └─┬ minimatch@0.2.14 │ │ │ ├── lru-cache@2.7.3 │ │ │ └── sigmund@1.0.1 │ │ ├── growl@1.8.1 │ │ ├─┬ jade@0.26.3 │ │ │ ├── commander@0.6.1 │ │ │ └── mkdirp@0.3.0 │ │ └─┬ mkdirp@0.5.0 │ │ └── minimist@0.0.8 │ ├── nan@1.3.0 │ ├── node-sass-middleware@0.3.1 │ ├── node-watch@0.3.5 │ ├── object-assign@1.0.0 │ ├─┬ sinon@1.10.3 │ │ ├─┬ formatio@1.0.2 │ │ │ └── samsam@1.1.3 │ │ └─┬ util@0.10.3 │ │ └── inherits@2.0.1 │ └── yargs@1.3.3

我无法使用最新版本的 NodeJS 5.2.0 和 NPM 3.5.2 安装 gulp-sass 的 0.7.3 版。 gulp-sass 的旧版本仅适用于旧版本的 NodeJS 0.12.9 和 NPM 2.14.9,另请参阅 https://github.com/sass/node-sass/issues/1166

看看这个:

"CMD.EXE was started with the above path as the current directory. UNC paths are not supported. Defaulting to Windows directory."

您可以使用pushd命令。作为网络共享上域用户的 --global 安装示例:

pushd \server\yourpath\user\AppData\Roaming\npm

提示:您可以通过在资源管理器中使用 %appdata%\npm 找出全局 npm 安装的正确路径,cmd 回答:

Z:\user\AppData\Roaming\npm>

现在您可以输入 "npm install node-sass"(或 gulp-sass 或其他)

Z:\user\AppData\Roaming\npm>npm install node-sass

没有 --global 或 -g,在这个路径中你是 "global"

如果完成,则popd断开Z:

我遇到了同样的问题,我通过简单的步骤修复了它。

真正的问题在于使用自动运行来设置命令提示符的路径。它与您的注册表有关。 我刚刚删除了命令处理器注册表中的自动运行文件,它开始正常工作。

加入