Cannot Install gulp-sass

╄→尐↘猪︶ㄣ 提交于 2019-12-08 19:37:42

问题


I'm trying to learn how to use gulp / sass / and all the other fun tools with Nodejs and I'm having an issue installing gulp-sass. The process I'm using to install everything is:

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

Once I get to step five, I get the following error:

$ 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

I'm trying this on my work computer, so I'm not sure if that matters. The system admin says there should not be any issue and other people have no issue with same package...and talking to them, they offer no help. I tried everything on my personal laptop and gulp-sass installs just fine, so it is something with my work pc.

My initial thought is it's a path issue, but then why do other packages install okay?

I did uninstall/reinstall Nodejs, but that didn't help.

Does anyone have an idea?

Thanks in advance!


回答1:


Your first guess was good as it is a matter of path name. From the error message :

UNC paths are not supported. Defaulting to Windows directory.

Npm needed to access \\primary\home\mendsley\...\node_modules\node-sass so as to execute the gulp-sass installation script. But this path is a UNC path (Uniform Naming Convention) and therefore is not supported.

As a consequence, the npm command defaulted to C:/Windows instead and tries to execute the installation script of gulp-sass (install.js) but this script is, as you might guess, not present in this directory.




回答2:


It could be a dependency hell problem with an older NodeJS or NPM version, too. gulp-sass depends on node-sass, which in turn depends on other packages, and they also depend on the right NodeJS and NPM version. For version 0.7.3 the full dependencies look like this:

├─┬ 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

I had trouble to install version 0.7.3 of gulp-sass with the latest versions of NodeJS 5.2.0 and NPM 3.5.2. This older version of gulp-sass worked only with the older version of NodeJS 0.12.9 and NPM 2.14.9, see also https://github.com/sass/node-sass/issues/1166




回答3:


Look at this:

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

You can use the pushd command. As example for --global Installation for a domain user on network share:

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

hint: you could figure out the right path for global npm installations by using %appdata%\npm in your Explorer, the cmd answers:

Z:\user\AppData\Roaming\npm>

now you can type "npm install node-sass" (or gulp-sass or whatever)

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

without --global or -g, in this path you are "global"

if finished, then popd to disconnect the Z:




回答4:


I had the same issue and I fixed it with simple step.

The real problem is with autorun to set the path of your command prompt. It is related to your registry. i just deleted the autorun file in registry for command processor and it started working normally.

Hop in this link



来源:https://stackoverflow.com/questions/31573847/cannot-install-gulp-sass

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!