Search code examples
user-interfacegradlenpmnode-sassenoent

Why can't NPMInstall build this node-sass dependency?


After trying to run "npm install" I've been getting this error that won't let me continue or even successfully run my gradle build.

Unable to save binary C:\path\node_modules\node-sass\vendor\win32-x64-59: { Error: ENOENT: no such file or directory, mkdir 'C:\path\node_modules\node-sass\vendor\win32-x64-59'
    at Object.fs.mkdirSync (fs.js:909:18)
    at checkAndDownloadBinary (C:\path\node_modules\node-sass\scripts\install.js:113:8)
    at Object.<anonymous> (C:\path\node_modules\node-sass\scripts\install.js:156:1)
    at Module._compile (module.js:662:30)
    at Object.Module._extensions..js (module.js:673:10)
    at Module.load (module.js:575:32)
    at tryModuleLoad (module.js:515:12)
    at Function.Module._load (module.js:507:3)
    at Function.Module.runMain (module.js:703:10)
    at startup (bootstrap_node.js:193:16)
  errno: -4058,
  code: 'ENOENT',
  syscall: 'mkdir',
  path: 'C:\path\\node_modules\\node-sass\\vendor\\win32-x64-59' }

I've tried editing the .npmrc file because initially the errors reported trying to download from an unavailable url, I added this line.

sass_binary_site=https://github.com/sass/node-sass/releases/download/v4.13.1/win32-x64-79_binding.node

I've also tried running "gradle uberClean", "npm uninstall node-sass" & "npm install node-sass", and deleted node-modules to start the build all over. Nothings worked. It also reports python errors at the same time but I'm unsure if it is related.

Building: C:\path\.gradle\nodejs_9.6.0\node-v9.6.0-win-x64\node.exe C:\path\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:\path\\.gradle\\nodejs_9.6.0\\node-v9.6.0-win-x64\\node.exe',
gyp verb cli   'C:\path\\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 [email protected]
gyp info using [email protected] | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb find Python checking Python explicitly set from command line or npm configuration
gyp verb find Python - "--python=" or "npm config get python" is "C:\Program Files\Python37\python.exe"
gyp verb find Python - executing "C:\Program Files\Python37\python.exe" to get executable path
gyp verb find Python - executable path is "C:\Program Files\Python37\python.exe"
gyp verb find Python - executing "C:\Program Files\Python37\python.exe" to get version
gyp verb find Python - version is "3.7.9"
gyp info find Python using Python version 3.7.9 found at "C:\Program Files\Python37\python.exe"
gyp verb get node dir no --target version specified, falling back to host node version: 9.6.0
gyp verb command install [ '9.6.0' ]
gyp verb install input version string "9.6.0"
gyp verb install installing version: 9.6.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 9.6.0
gyp verb ensuring nodedir is created C:\Users\bryce.eller\AppData\Local\node-gyp\Cache\9.6.0
gyp WARN install got an error, rolling back install
gyp verb command remove [ '9.6.0' ]
gyp verb remove using node-gyp dir: C:\Users\bryce.eller\AppData\Local\node-gyp\Cache
gyp verb remove removing target version: 9.6.0
gyp verb remove removing development files for version: 9.6.0
gyp ERR! configure error
gyp ERR! stack Error: ENOENT: no such file or directory, mkdir 'C:\Users\bryce.eller\AppData\Local\node-gyp\Cache\9.6.0'gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\path\\.gradle\\nodejs_9.6.0\\node-v9.6.0-win-x64\\node.exe" "C:\path\\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:\path\node_modules\node-sass
gyp ERR! node -v v9.6.0
gyp ERR! node-gyp -v v7.1.2
gyp ERR! not ok
Build failed with error code: 1
npm WARN [email protected] requires a peer of leaflet@~1.3.1 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\watchpack\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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:\path\npm-cache\_logs\2021-08-05T14_12_09_736Z-debug.log

Any tips on how to get my build successfully working again would be awesome! Thanks in advance!


Solution

  • Lots of things can cause this. Most common I think is NVM. Use it to switch versions and caches can get messed up. Suggestions.

    1. Switch to pure-JS version of Saas: https://www.npmjs.com/package/sass
    2. Clear cache directory: C:\Users\bryce.eller\AppData\Local\node-gyp\Cache
    3. If not initial install already, remove node_modules and install from scratch
    4. Upgrade version of node-sass

    node-sass is notorious for having compilation errors; locally and on CI servers. If you have control over the project I would strongly recommend switching to a JS-only version.