当前位置: 首页 > 知识库问答 >
问题:

npm安装错误:'gyp'失败,退出代码: 1

赖绪
2023-03-14

我正在尝试使用NPM5.6.0在Windows 10上安装模块。当我进入npm安装时,我得到:

gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (C:\Users\xiaooming\Desktop\app\node_modules\node-gyp\lib\configure.js:336:16)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "D:\\Program Files\\nodejs\\node.exe" "C:\\Users\\xiaooming\\Desktop\\app\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Users\xiaooming\Desktop\app\node_modules\node-sass
gyp ERR! node -v v8.10.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1
npm WARN kingt4.0app@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: 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\xiaooming\AppData\Roaming\npm-cache\_logs\2018-03-18T13_02_03_946Z-debug.log

似乎节点sass安装错误。环境如下:

Python版本:2.7.14

npm版本:5.6.0

节点版本:8.10.0

ruby版本: 2.3.3p222 (2016-11-21修订56859)[i386-mingw32]

系统:win10(x64)

node-gyp: 3.6.2

而且我已经安装了Microsoft Visual Studio Express 2015,Bellow命令已经执行:

npm config set msvs_version 2015
node-gyp configure --msvs_version=2015
npm install --global --production windows-build-tools

package.json是:

{
  "name": "kingt4.0app",
  "version": "1.0.0",
  "description": "an kingt4.0 project.",
  "main": "index.js",
  "scripts": {
    "test": "test.js"
  },
  "keywords": [
    "finance"
  ],
  "author": "kingdom",
  "license": "ISC",
  "devDependencies": {
    "browser-sync": "^2.11.1",
    "gulp": "^3.9.1",
    "gulp-autoprefixer": "^3.1.0",
    "gulp-cache": "^0.4.2",
    "gulp-changed": "^1.3.2",
    "gulp-clean-css": "^2.0.2",
    "gulp-file-include": "^0.13.7",
    "gulp-if": "^2.0.0",
    "gulp-imagemin": "^2.4.0",
    "gulp-rename": "^1.2.2",
    "gulp-sass": "^2.2.0",
    "gulp-sourcemaps": "^1.6.0",
    "gulp.spritesmith": "^6.2.1",
    "imagemin-jpegtran": "^4.3.2",
    "imagemin-pngquant": "^4.2.2",
    "merge-stream": "^1.0.0",
    "normalize.css": "^4.0.0",
    "spritesheet-templates": "^10.1.2",
    "vinyl-buffer": "^1.0.0"
  },
  "dependencies": {
    "remodal": "^1.0.7",
    "slick-carousel": "^1.6.0"
  }
}

如何解决这个问题?谢谢你的帮助。

共有3个答案

袁运良
2023-03-14

尝试下面的这个命令,看看这是否消除了这个问题。我的mac电脑上有catalina,这个命令消除了这个问题。


npm i -g node-gyp@latest && npm config set node_gyp "/usr/local/lib/node_modules/node-gyp/bin/node-gyp.js"
衡泰
2023-03-14

这对我有用。逐个运行下面的命令

rm -rf node_modules
rm package-lock.json
npm update
npm install
丁和歌
2023-03-14

如果这是一台苹果机(OSX),这就是你能做的

使用终端

xcode-select --print-path

然后删除已安装的版本

sudo rm -r -f /Library/Developer/CommandLineTools

并重新安装

xcode-select --install

这应该能解决问题

Ref:gyp:未检测到macOS Catalina的Xcode或CLT版本

 类似资料:
  • 我们有问题运行“NPM安装”在我们的项目。找不到某个文件: 对于我们来说,这个节点--陀螺似乎是一个永无止境的痛苦之源。一开始它抱怨它需要python,所以我们安装了它。然后它抱怨它需要我们安装的VCBuild,(使用.NET2.0SDK),现在我们出现了这个错误。这几乎就像是错误越来越模糊,感觉我们走上了一条错误的道路。 奇怪的是,我们团队中的其他人在运行NPM-Install时没有任何问题。

  • 当我用Angular在我的项目上安装npm时。节点sass/node gyp安装失败,错误显示如下: $npm安装 节点-sass@4.10.0安装C:\Users\d\Documents\project\app\node\u modules\node sass node scripts/install.js 从https://github.com/sass/node-sass/releases/

  • 问题内容: 重新安装Node和Git后尝试运行时收到以下错误 任何人都不知道是什么原因导致的,以及如何解决它? (已删除公司详细信息) 问题答案: 建议的第一步是使用最新的npm: (您可能需要)。您正在使用npm 2.x,最新的是3.5.x。

  • 我是新来的节点,有点超出我的深度。在Mac OS X和Centos 6上都遇到此错误。发生在我尝试过的所有npm install xxx命令中。任何关于如何避免这一错误的建议都将不胜感激。 类似于npm,安装时会出现节点gyp错误,但我的用户名中没有空格,这就解决了他的问题。

  • 我有一个单一的. rs文件。当我用编译它时,我得到一个错误: 我见过一些与此相关的话题,但没有一个能帮助我解决问题。

  • 问题内容: 我有一个使用和的NPM项目,都需要node-gyp来安装它们。当我这样做时,出现以下错误: 以前由于未安装Python 2.7而失败,现在是这样。这让我头疼。我该怎么办? 问题答案: 下面的答案代表手动安装,但是有一种简单得多的方法:自动安装。 以管理员身份打开Powershell并运行。 安装需要时间,但对我来说却像一个魅力!