node-sass 报错记录The module XXXX/win32-x64-93_binding.node was compiled against a different Node.js ver
vue项目运行时报错
Binary found at D:\Googledownload\win32-x64-93_binding.node
Testing binary
Binary has a problem: Error: The module '\\?\D:\Googledownload\win32-x64-93_binding.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 93. This version of Node.js requires
NODE_MODULE_VERSION 72. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1057:18)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at module.exports (D:\javacode\metroexam-ui-user\node_modules\node-sass\lib\binding.js:19:10)
at Object.<anonymous> (D:\javacode\metroexam-ui-user\node_modules\node-sass\lib\index.js:14:35)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
Building the binary locally
Building: C:\Program Files\nodejs\node.exe D:\javacode\metroexam-ui-user\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 [
gyp verb cli 'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli 'D:\\javacode\\metroexam-ui-user\\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 verb cli ]
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 download using dist-url https://npm.taobao.org/dist
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 (D:\javacode\metroexam-ui-user\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (D:\javacode\metroexam-ui-user\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (D:\javacode\metroexam-ui-user\node_modules\which\which.js:80:29)
gyp verb `which` failed at D:\javacode\metroexam-ui-user\node_modules\which\which.js:89:16
gyp verb `which` failed at D:\javacode\metroexam-ui-user\node_modules\isexe\index.js:42:5
gyp verb `which` failed at D:\javacode\metroexam-ui-user\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqCallback.oncomplete (fs.js:168:21)
gyp verb `which` failed python2 Error: not found: python2
gyp verb `which` failed at getNotFoundError (D:\javacode\metroexam-ui-user\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (D:\javacode\metroexam-ui-user\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (D:\javacode\metroexam-ui-user\node_modules\which\which.js:80:29)
gyp verb `which` failed at D:\javacode\metroexam-ui-user\node_modules\which\which.js:89:16
gyp verb `which` failed at D:\javacode\metroexam-ui-user\node_modules\isexe\index.js:42:5
gyp verb `which` failed at D:\javacode\metroexam-ui-user\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqCallback.oncomplete (fs.js:168:21) {
gyp verb `which` failed code: 'ENOENT'
gyp verb `which` failed }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python D:\anaconda\python.EXE
gyp ERR! configure error
gyp ERR! stack Error: Command failed: D:\anaconda\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "<string>", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:308:12)
gyp ERR! stack at ChildProcess.emit (events.js:314:20)
gyp ERR! stack at maybeClose (internal/child_process.js:1022:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
gyp ERR! System Windows_NT 10.0.19045
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\javacode\\metroexam-ui-user\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd D:\javacode\metroexam-ui-user\node_modules\node-sass
gyp ERR! node -v v12.22.6
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
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.
这些报错着实看着头大,除去哪些gyp开头的先别看,但首先要冷静,摘取一下关键信息
Binary has a problem: Error: The module '\\?\D:\Googledownload\win32-x64-93_binding.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 93. This version of Node.js requires
NODE_MODULE_VERSION 72.
问题似乎是这个啥啥啥module的版本有问题,又去查了一下nodejs和NODE_MODULE_VERSION版本对应,发现没啥用
但93和72这个应该是个问题切入点,直接去搜了win32-x64-93_binding.node这个文件,发现和就是node-sass模块文件!
看到这里心里大概就明白了,于是去查看各版本的node-sass,链接
项目中用的node-sass是4.14.1,于是进入这里看看
发现在这个版本下的win-x64-xx是没有93后缀的,所有问题出在这里,vue在install找的文件错了
然后把win32-x64-72_binding.node下载下来,替换到报错信息下的那个文件目录,比如我的是:
再次npm install就行
补充背景信息,这个错可能花了两三天才解决,期间一直在重装nodejs和node-sass,网上的解决办法大多都是要你重装这两个东西,大概也猜的出来可能是版本问题,可是在接连重装好多版本后都不能解决
我的猜测:可能是在这个项目第一次运行时,win32-x64-93_binding.node就和那个版本的node-sass绑定了,是一一对应的关系;在后续的卸载再重装node-sass时,这个文件没有手动删除,与后续的nodejs或者node-sass环境存在冲突,所以一直会报sass相关错误,但重装也不能解决的原因
教训:仔仔细细看报错原因才是正确的,一股脑地去查csdn行不通