首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >npm安装失败,错误:`gyp`,退出代码:1

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

Stack Overflow用户
提问于 2018-03-18 21:36:18
回答 16查看 76.9K关注 0票数 37

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

代码语言:javascript
运行
复制
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

似乎是node-sass安装错误。环境如下:

python版本:2.7.14

npm版本: 5.6.0

节点版本:8.10.0

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

系统:Win10(X64)

node-gyp:3.6.2

我已经安装了Microsoft Visual Studio express 2015,下面的命令已经执行:

代码语言:javascript
运行
复制
npm config set msvs_version 2015
node-gyp configure --msvs_version=2015
npm install --global --production windows-build-tools

package.json为:

代码语言:javascript
运行
复制
{
  "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"
  }
}

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

EN

回答 16

Stack Overflow用户

发布于 2020-03-26 12:17:56

如果这是一台mac计算机(OSX),您可以执行以下操作

使用终端

代码语言:javascript
运行
复制
xcode-select --print-path

然后删除已安装的版本

代码语言:javascript
运行
复制
sudo rm -r -f /Library/Developer/CommandLineTools

并重新安装

代码语言:javascript
运行
复制
xcode-select --install

这应该可以解决问题。

参考:gyp: No Xcode or CLT version detected macOS Catalina

票数 78
EN

Stack Overflow用户

发布于 2020-03-02 12:33:32

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

代码语言:javascript
运行
复制
rm -rf node_modules
rm package-lock.json
npm update
npm install
票数 29
EN

Stack Overflow用户

发布于 2020-04-05 02:03:06

尝试下面的命令,看看是否消除了这个问题。我在我的mac上安装了catalina,这个命令消除了这个问题。

代码语言:javascript
运行
复制
npm i -g node-gyp@latest && npm config set node_gyp "/usr/local/lib/node_modules/node-gyp/bin/node-gyp.js"
票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49348482

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档