NPM node-sass 安装失败
NPM node-sass installation fails
我正在尝试在一个项目中安装 node-sass,它可以在我的电脑上完美构建和运行,但从表面上看,我在尝试安装软件包时遇到了重大问题。
注意:我已经多次尝试重新安装和重建项目。
错误总结:
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio17\BuildTools\MSBuild.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\Max-T\Documents\Sources\StaffMangerV2\black-dashboard-pro-react-v1.0.0\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:210:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\Max-T\Documents\Sources\StaffMangerV2\black-dashboard-pro-react-v1.0.0\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Users\Max-T\Documents\Sources\StaffMangerV2\black-dashboard-pro-react-v1.0.0\node_modules\node-sass
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\react-scripts\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: 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@4.11.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.11.0 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\Max-T\AppData\Roaming\npm-cache\_logs19-10-30T10_05_01_386Z-debug.log
package.json => https://hastebin.com/azetegukes.pl
代码太多,所以我不得不将其粘贴到其他地方。
您使用的是 Node 12,node-sass 至少需要 4.12 才能支持该版本 https://github.com/sass/node-sass#node-version-support-policy
试试这个对我有用的命令
sudo npm install -g --unsafe-perm node-sass
经过2个多小时尝试各种方式(清理npm缓存,删除node_modules,尝试使用全局开关安装-g
等)安装node-sass 每次都失败了,我终于把镜子换成了中国,它立即对我有用!! (我知道这有点没有任何意义,考虑到我得到的错误)
仅供参考,这是我在它最终起作用之前收到的错误:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.14.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.14.0 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\****\AppData\Roaming\npm-cache\_logs20-06-06T13_56_56_768Z-debug.log
我的节点版本:v12.18.0
package.json 中的节点-sass 版本:“^4.14.0”
我按照 node-sass npm page 中的说明更改了镜像。
npm install -g mirror-config-china --registry=http://registry.npm.taobao.org
npm install node-sass
希望对您有所帮助。
如果最近有人遇到这个问题...最简单的解决方法是将 node-sass 替换为 sass 在你的依赖项中。这是最近维护的版本,我只需更改 1 行代码及其初始化方式,并且我现有的所有代码都已经兼容。
https://sass-lang.com/blog/libsass-is-deprecated 如何迁移 下有更多详细信息。
最好的选择可能是用 sass
替换 node-sass
库。
但在我们的例子中,我通过安装 nvm
并将本地节点版本设置为 14.17.6 来解决这个问题
我的 node-sass 版本是 4.14.1
我正在尝试在一个项目中安装 node-sass,它可以在我的电脑上完美构建和运行,但从表面上看,我在尝试安装软件包时遇到了重大问题。
注意:我已经多次尝试重新安装和重建项目。
错误总结:
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio17\BuildTools\MSBuild.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\Max-T\Documents\Sources\StaffMangerV2\black-dashboard-pro-react-v1.0.0\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:210:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\Max-T\Documents\Sources\StaffMangerV2\black-dashboard-pro-react-v1.0.0\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Users\Max-T\Documents\Sources\StaffMangerV2\black-dashboard-pro-react-v1.0.0\node_modules\node-sass
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\react-scripts\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: 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@4.11.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.11.0 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\Max-T\AppData\Roaming\npm-cache\_logs19-10-30T10_05_01_386Z-debug.log
package.json => https://hastebin.com/azetegukes.pl 代码太多,所以我不得不将其粘贴到其他地方。
您使用的是 Node 12,node-sass 至少需要 4.12 才能支持该版本 https://github.com/sass/node-sass#node-version-support-policy
试试这个对我有用的命令
sudo npm install -g --unsafe-perm node-sass
经过2个多小时尝试各种方式(清理npm缓存,删除node_modules,尝试使用全局开关安装-g
等)安装node-sass 每次都失败了,我终于把镜子换成了中国,它立即对我有用!! (我知道这有点没有任何意义,考虑到我得到的错误)
仅供参考,这是我在它最终起作用之前收到的错误:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.14.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.14.0 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\****\AppData\Roaming\npm-cache\_logs20-06-06T13_56_56_768Z-debug.log
我的节点版本:v12.18.0
package.json 中的节点-sass 版本:“^4.14.0”
我按照 node-sass npm page 中的说明更改了镜像。
npm install -g mirror-config-china --registry=http://registry.npm.taobao.org
npm install node-sass
希望对您有所帮助。
如果最近有人遇到这个问题...最简单的解决方法是将 node-sass 替换为 sass 在你的依赖项中。这是最近维护的版本,我只需更改 1 行代码及其初始化方式,并且我现有的所有代码都已经兼容。
https://sass-lang.com/blog/libsass-is-deprecated 如何迁移 下有更多详细信息。
最好的选择可能是用 sass
替换 node-sass
库。
但在我们的例子中,我通过安装 nvm
并将本地节点版本设置为 14.17.6 来解决这个问题
我的 node-sass 版本是 4.14.1