1

在尝试运行“npm install”后,我收到了这个错误,无法继续,甚至无法成功运行我的 gradle 构建。

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' }

我尝试编辑 .npmrc 文件,因为最初报告的错误试图从不可用的 url 下载,我添加了这一行。

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

我还尝试运行“gradle uberClean”、“npm uninstall node-sass”和“npm install node-sass”,并删除了节点模块以重新开始构建。没有任何效果。它还同时报告 python 错误,但我不确定它是否相关。

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 node-gyp@7.1.2
gyp info using node@9.6.0 | 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 leaflet.markercluster@1.4.1 requires a peer of leaflet@~1.3.1 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules\watchpack\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@6.0.1 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@6.0.1 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

关于如何让我的构建再次成功运行的任何提示都会很棒!提前致谢!

4

2 回答 2

0

Node 9 于 2018 年 6 月终止使用。我建议至少迁移到 Node 12 的当前 LTS 版本。该版本的 node-sass https://github.com/sass/node-sass#支持这一点节点版本支持策略

于 2021-08-06T20:08:11.323 回答
0

很多事情都可能导致这种情况。我认为最常见的是 NVM。使用它来切换版本和缓存可能会搞砸。建议。

  1. 切换到纯 JS 版本的 Saas:https ://www.npmjs.com/package/sass
  2. 清除缓存目录:C:\Users\bryce.eller\AppData\Local\node-gyp\Cache
  3. 如果尚未初始安装,node_modules请从头开始删除并安装
  4. 升级版node-sass

node-sass因编译错误而臭名昭著;在本地和 CI 服务器上。如果您可以控制项目,我强烈建议您切换到纯 JS 版本。

于 2021-08-05T14:42:50.420 回答