npm just won't install node sass

我只是一个虾纸丫 提交于 2019-12-22 05:18:10

问题


I first encountered the issue when trying to use ionic and it needed the dependency for its templates. Then when I tried to install node-sass with npm myself the issue persisted. This is on Windows 10 Version 1703, both nodejs 6.11.3 and nodejs 8.4.0 tried out, ended up with same result. And VPN, http proxy were tried with no luck. Basically, it's saying :

Cannot download "https://github.com/sass/node-sass/releases/download/v4.5.3/win32-x64-57_binding.node"

when nothing is fiddled with ,it says :

connect ECONNREFUSED 127.0.0.1:443

when using npm set config proxy,it says something like:

tunnel cannot be established

when using VPN,it waits forever at :

node scripts/install.js

or outputs the same as if nothing is fiddled with.

When reporting an bug, you must provide this information:

  • NPM version (npm -v): 5.3.0 with node latest(8.4.0), default version with node 6.11.3
  • Node version (node -v):LTS(6.11.3) and LATEST(8.4.0)
  • Node Process (node -p process.versions):

    { http_parser: '2.7.0', node: '8.4.0', v8: '6.0.286.52', uv: '1.13.1', zlib: '1.2.11', ares: '1.10.1-DEV', modules: '57', nghttp2: '1.22.0', openssl: '1.0.2l', icu: '59.1', unicode: '9.0', cldr: '31.0.1', tz: '2017b' }

  • Node Platform (node -p process.platform): win32
  • Node architecture (node -p process.arch): x64
  • node-sass version (node -p "require('node-sass').info"): Error: Cannot find module 'node-sass'
  • npm node-sass versions (npm ls node-sass): `-- (empty)

and there is the output

---> npm install -g node-sass
C:\Users\rick\AppData\Roaming\npm\node-sass -> C:\Users\rick\AppData\Roaming\npm\node_modules\node-sass\bin\node-sass

> node-sass@4.5.3 install C:\Users\rick\AppData\Roaming\npm\node_modules\node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.5.3/win32-x64-57_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.5.3/win32-x64-57_binding.node":

connect ECONNREFUSED 127.0.0.1:443

Hint: If github.com is not accessible in your location
      try setting a proxy via HTTP_PROXY, e.g.

      export HTTP_PROXY=http://example.com:1234

or configure npm proxy via

      npm config set proxy http://example.com:8080

> node-sass@4.5.3 postinstall C:\Users\rick\AppData\Roaming\npm\node_modules\node-sass
> node scripts/build.js

Building: C:\Program Files\nodejs\node.exe C:\Users\rick\AppData\Roaming\npm\node_modules\node-sass\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli   'C:\\Users\\rick\\AppData\\Roaming\\npm\\node_modules\\node-sass\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library=' ]
gyp info using node-gyp@3.6.2
gyp info using node@8.4.0 | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\Users\rick\AppData\Roaming\npm\node_modules\node-sass\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\Users\rick\AppData\Roaming\npm\node_modules\node-sass\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\Users\rick\AppData\Roaming\npm\node_modules\node-sass\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\Users\rick\AppData\Roaming\npm\node_modules\node-sass\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\Users\rick\AppData\Roaming\npm\node_modules\node-sass\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at C:\Users\rick\AppData\Roaming\npm\node_modules\node-sass\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:152:21)
gyp verb `which` failed  python2 { Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\Users\rick\AppData\Roaming\npm\node_modules\node-sass\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\Users\rick\AppData\Roaming\npm\node_modules\node-sass\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\Users\rick\AppData\Roaming\npm\node_modules\node-sass\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\Users\rick\AppData\Roaming\npm\node_modules\node-sass\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\Users\rick\AppData\Roaming\npm\node_modules\node-sass\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at C:\Users\rick\AppData\Roaming\npm\node_modules\node-sass\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:152:21)
gyp verb `which` failed   stack: 'Error: not found: python2\n    at getNotFoundError (C:\\Users\\rick\\AppData\\Roaming\\npm\\node_modules\\node-sass\\node_modules\\which\\which.js:13:12)\n    at F (C:\\Users\\rick\\AppData\\Roaming\\npm\\node_modules\\node-sass\\node_modules\\which\\which.js:68:19)\n    at E (C:\\Users\\rick\\AppData\\Roaming\\npm\\node_modules\\node-sass\\node_modules\\which\\which.js:80:29)\n    at C:\\Users\\rick\\AppData\\Roaming\\npm\\node_modules\\node-sass\\node_modules\\which\\which.js:89:16\n    at C:\\Users\\rick\\AppData\\Roaming\\npm\\node_modules\\node-sass\\node_modules\\isexe\\index.js:42:5\n    at C:\\Users\\rick\\AppData\\Roaming\\npm\\node_modules\\node-sass\\node_modules\\isexe\\windows.js:36:5\n    at FSReqWrap.oncomplete (fs.js:152:21)',
gyp verb `which` failed   code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python C:\Program Files\Python36\python.EXE
gyp verb check python version `C:\Program Files\Python36\python.EXE -c "import platform; print(platform.python_version());"` returned: "3.6.2\r\n"
gyp verb could not find "C:\Program Files\Python36\python.EXE". checking python launcher
gyp verb could not find "C:\Program Files\Python36\python.EXE". guessing location
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "C:\Program Files\Python36\python.EXE", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (C:\Users\rick\AppData\Roaming\npm\node_modules\node-sass\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack     at PythonFinder.<anonymous> (C:\Users\rick\AppData\Roaming\npm\node_modules\node-sass\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack     at C:\Users\rick\AppData\Roaming\npm\node_modules\node-sass\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\rick\\AppData\\Roaming\\npm\\node_modules\\node-sass\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Users\rick\AppData\Roaming\npm\node_modules\node-sass
gyp ERR! node -v v8.4.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.5.3 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.5.3 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\rick\AppData\Roaming\npm-cache\_logs\2017-09-10T18_52_13_062Z-debug.log

Then someone tells me:

Well ECONNREFUSED is easy - you have configured npm to talk to the proxy at 127.0.0.1 (localhost) port 443 but the proxy does not seem to be active for this port. Please check proxy/VPN software configuration - port numbers must match.

But the thing is I don't have proxy configured. I tried npm config rm proxy,and npm config delete proxy, I even tried just go with it and set up a proxy then point npm to that proxy like I described above, nothing works.And here is the powershell enviroment config just in case:

⚡ rick@DESKTOP-1NVA03E  ~  $reg = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"

⚡ rick@DESKTOP-1NVA03E  ~  $settings = Get-ItemProperty -Path $reg                                                    

⚡ rick@DESKTOP-1NVA03E  ~  $settings.ProxyServer
127.0.0.1:1080 

⚡ rick@DESKTOP-1NVA03E  ~  $settings.ProxyEnable
0

回答1:


I just came across the same problem. It was solved by installing Python v2.7 in C:\Python27\ . (I previously only had Python 3.6 installed in C:\Program Files\Python36\ )




回答2:


it looks like compatibility issue of the node-sass module. You can solve this issue by following a few steps.

give the below command in your terminal

node list node-sass

It will list all your node-sass dependencies( including nested dependencies)

check all versions of node sass and also check supported node-sass for Node.js installed in your machine

You can either change the Node.js version in your machine or add the following code in package.json

    "resolutions": {
        "*/node-sass": "*"
     },

Remove node_module folder and yarn.lock file (assuming that you use yarn) once you make the above change.

Install the node_modules using yarn install

If you prefer npm instead of yarn you might need to install an additional package called npm force resolutions




回答3:


I had this issue for days looking for possible answers. I downgraded my node.js from 9.3.0 to v6.12.2 and run (all errors were gone):

        npm update

Hopefully, this can help some of you who have encountered similar errors.




回答4:


I have resolved this issue by changing compatible version of node.

It may be problem of compatibility of node version with node-sass version you are using. Please check the below document to see the compatibility table and install appropriate node version.



来源:https://stackoverflow.com/questions/46173180/npm-just-wont-install-node-sass

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