问题:入职公司,接手项目yarn初始化项目一直失败崩溃啊!!!!!!!
报错内容:
error D:\xxx\xxx\node_modules\node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: D:\xxx\xxx\node_modules\node-sass
Output:
Binary found at D:\software\nodesass\win32-x64-72_binding.node
Testing binary
Binary has a problem: Error: The module '\\?\D:\software\nodesass\win32-x64-72_binding.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 64. 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:717:18)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
gyp ERR! System Windows_NT 10.0.19042
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\xxx\\xxx\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd D:\xxx\xxx\node_modules\node-sass
gyp ERR! node -v v16.13.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
提升node版本16.13和package.json里面"node-sass": “^4.14.1” 不匹配
然后就是安装node的版本控制工具nvm;用nvm安装对应的node版本
一顿操作猛如虎最后node版本安装了五六个还是没解决问题啊
网上博客都不靠谱啊!!!!
**
**
一、根目录创建 .npmrc 文件
二、在.npmrc文件里面写入 下面代码
sass_binary_site = https://npmmirror.com/mirrors/node-sass/
registry = https://registry.npmmirror.com/
三、然后删除之前拉取的文件
1、删除拉取的node_modules文件夹
2、删除yarn.lock文件(有yarn-log文件的一起删除)
3、删除package-lock.json文件
然后你就执行 yarn 或者 npm install 命令
静静的等待成功吧;爱你么么哒!!!!!!!
亲自测试有效;比网上介绍的换node版本或者node-sass版本简单有效