npm install:在 node-sass@3.13.1 安装后脚本失败
npm install: Failed at the node-sass@3.13.1 postinstall script
我有一个 angular 申请:https://github.com/XBITSwitzerland/ngx-admin/tree/ng2-admin
现在我尝试做:npm install
但是我得到这个错误(命令的竞争输出太长,所以我只在这里分享最后一部分):
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\github\ngx-admin\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\github\ngx-admin\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\github\ngx-admin\node_modules\wintersmith-sassy\node_modules\node-sass
gyp ERR! node -v v10.15.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1
npm WARN ngx-toastr@4.4.1 requires a peer of @angular/core@^2.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN ngx-toastr@4.4.1 requires a peer of @angular/common@^2.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\webpack-dev-server\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.4 (node_modules\watchpack\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.1.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@3.13.1 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@3.13.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:\Users\danyb\AppData\Roaming\npm-cache\_logs19-01-29T18_25_12_699Z-debug.log
有人知道为什么会出现此错误以及如何解决吗?
我认为这是因为您缺少 node-sass 模块。尝试以下操作并重新运行您的构建脚本,看看是否能解决您的问题:
npm install node-sass@latest
此外,我看到您在 Windows 平台上使用 fsevents,只是警告此模块仅支持对 OS X FSEvents[=12= 的本机访问]
如果您运行遇到这个问题,请阅读此页面:https://www.bramvandenbulcke.be/en/kb/failed-node-sass3131-postinstall-script
我的解决方案:
1) 删除 package-lock.json
文件
2) npm install gulp-sass --save-dev
3) npm install node-sass@latest
版本特定说明:
node-sass@3.13.1
运行s 仅适用于 Node.js
v7 版本,如 release notes 中所述:
收到此消息后我在 npm 安装上遇到错误 node-sass@3.13.1 postinstall: node scripts/build.js
> node scripts/install.js
Downloading binary from https://github.com/sass/node-sass/releases/download/v3.13.1/linux-x64-72_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/linux-x64-72_binding.node":
HTTP error 404 Not Found
Hint: If github.com is not accessible in your location
try setting a proxy via HTTP_PROXY, e.g.
export HTTP_PROXY=http://example.com:1234
or configure npm proxy via
npm config set proxy http://example.com:8080
> core-js@2.6.9 postinstall /var/www/my/armat/www/node_modules/core-js
> node scripts/postinstall || echo "ignore"
并花了数小时寻找解决方案。我试图将它安装在使用旧版本节点和 npm 的 laravel 5.2
上,这对我有帮助
$ npm install -g n
$ n 6.10.2 // selecting version you need in my case 6.10.2
$ npm install -g npm@3.10.10 // same for npm
希望这对其他人有帮助^_^
#######更新###########
nvm install 6.10.2
nvm use 6.10.2
npm install -g npm@3.10.10
我也收到同样的错误
"npm 错误!代码 ELIFECYCLE
错误!错误号 1
npm 错误!节点-sass@3.13.1 安装后:node scripts/build.js
错误!退出状态 1
错误!
错误!在 node-sass@3.13.1 安装后脚本失败。
错误!这可能不是 npm 的问题。上面可能有额外的日志输出。"
解法:
我将 node-sass 和 gulp-sass 版本增加到 package.json 文件中的最新版本,然后问题得到解决。
仅删除
package-lock.json
文件
再做一次npm install
对我来说,问题出在 Linux 目录权限上。即使使用 sudo 和 root 用户我也无法让它工作。
我的解决方案是更改项目目录所有者,如下所示:
sudo chown my_user:my_user -R /path/to/project
分别执行以下命令:
rm -rf package-lock.json
npm install node-sass@latest
如果您在错误输出中进一步向上滚动,您会看到如下内容:
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
您可以通过以下步骤在 windows 上修复它:
- 删除
node_modules
文件夹
- 运行
npm install --global windows-build-tools
在 powershell 中作为管理员
- 正在使用
npm install
重新安装节点模块或节点-sass
对于Ubuntu
删除包-lock.json文件
sudo npm install gulp-sass --save-dev
sudo npm install node-sass@latest
如果您使用 Visual Studio 运行 以下命令:
npm cache clean --force
npm config set msvs_version 2019 --global
其中 2019 是 Visual Studio
的版本
如果您正在使用 OpenBSD,那是因为您需要 g++。使用
安装
pkg_add g++
但是,它作为 ec++ 安装在 /usr/local/bin,因此您可以复制、重命名或 使用以下方法创建符号链接:
ln -s /usr/local/bin/ec++ /usr/local/bin/g++
再次执行 npm install,它应该可以工作
我有一个 angular 申请:https://github.com/XBITSwitzerland/ngx-admin/tree/ng2-admin
现在我尝试做:npm install
但是我得到这个错误(命令的竞争输出太长,所以我只在这里分享最后一部分):
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\github\ngx-admin\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\github\ngx-admin\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\github\ngx-admin\node_modules\wintersmith-sassy\node_modules\node-sass
gyp ERR! node -v v10.15.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1
npm WARN ngx-toastr@4.4.1 requires a peer of @angular/core@^2.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN ngx-toastr@4.4.1 requires a peer of @angular/common@^2.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\webpack-dev-server\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.4 (node_modules\watchpack\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.1.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@3.13.1 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@3.13.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:\Users\danyb\AppData\Roaming\npm-cache\_logs19-01-29T18_25_12_699Z-debug.log
有人知道为什么会出现此错误以及如何解决吗?
我认为这是因为您缺少 node-sass 模块。尝试以下操作并重新运行您的构建脚本,看看是否能解决您的问题:
npm install node-sass@latest
此外,我看到您在 Windows 平台上使用 fsevents,只是警告此模块仅支持对 OS X FSEvents[=12= 的本机访问]
如果您运行遇到这个问题,请阅读此页面:https://www.bramvandenbulcke.be/en/kb/failed-node-sass3131-postinstall-script
我的解决方案:
1) 删除 package-lock.json
文件
2) npm install gulp-sass --save-dev
3) npm install node-sass@latest
版本特定说明:
node-sass@3.13.1
运行s 仅适用于 Node.js
v7 版本,如 release notes 中所述:
收到此消息后我在 npm 安装上遇到错误 node-sass@3.13.1 postinstall: node scripts/build.js
> node scripts/install.js
Downloading binary from https://github.com/sass/node-sass/releases/download/v3.13.1/linux-x64-72_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/linux-x64-72_binding.node":
HTTP error 404 Not Found
Hint: If github.com is not accessible in your location
try setting a proxy via HTTP_PROXY, e.g.
export HTTP_PROXY=http://example.com:1234
or configure npm proxy via
npm config set proxy http://example.com:8080
> core-js@2.6.9 postinstall /var/www/my/armat/www/node_modules/core-js
> node scripts/postinstall || echo "ignore"
并花了数小时寻找解决方案。我试图将它安装在使用旧版本节点和 npm 的 laravel 5.2
上,这对我有帮助
$ npm install -g n
$ n 6.10.2 // selecting version you need in my case 6.10.2
$ npm install -g npm@3.10.10 // same for npm
希望这对其他人有帮助^_^
#######更新###########
nvm install 6.10.2
nvm use 6.10.2
npm install -g npm@3.10.10
我也收到同样的错误
"npm 错误!代码 ELIFECYCLE
错误!错误号 1
npm 错误!节点-sass@3.13.1 安装后:node scripts/build.js
错误!退出状态 1
错误!
错误!在 node-sass@3.13.1 安装后脚本失败。
错误!这可能不是 npm 的问题。上面可能有额外的日志输出。"
解法:
我将 node-sass 和 gulp-sass 版本增加到 package.json 文件中的最新版本,然后问题得到解决。
仅删除
package-lock.json
文件
再做一次npm install
对我来说,问题出在 Linux 目录权限上。即使使用 sudo 和 root 用户我也无法让它工作。
我的解决方案是更改项目目录所有者,如下所示:
sudo chown my_user:my_user -R /path/to/project
分别执行以下命令:
rm -rf package-lock.json
npm install node-sass@latest
如果您在错误输出中进一步向上滚动,您会看到如下内容:
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
您可以通过以下步骤在 windows 上修复它:
- 删除
node_modules
文件夹 - 运行
npm install --global windows-build-tools
在 powershell 中作为管理员 - 正在使用
npm install
重新安装节点模块或节点-sass
对于Ubuntu
删除包-lock.json文件
sudo npm install gulp-sass --save-dev
sudo npm install node-sass@latest
如果您使用 Visual Studio 运行 以下命令:
npm cache clean --force
npm config set msvs_version 2019 --global
其中 2019 是 Visual Studio
的版本如果您正在使用 OpenBSD,那是因为您需要 g++。使用
安装pkg_add g++
但是,它作为 ec++ 安装在 /usr/local/bin,因此您可以复制、重命名或 使用以下方法创建符号链接:
ln -s /usr/local/bin/ec++ /usr/local/bin/g++
再次执行 npm install,它应该可以工作