【问题标题】:Both 'npm install' & 'yarn install' end up with an error“npm install”和“yarn install”都以错误告终
【发布时间】:2018-11-15 23:10:59
【问题描述】:

最近我的环境/节点遇到了很多麻烦。

npm install / yarn install 都报错,不管我是用 homebrew 安装 Node 还是通过官网的 .pkg 安装。

package.json的内容

{
  "private": true,
  "engines": {
    "node": ">=4"
  },
  "devDependencies": {
    "babel-core": "^6.4.0",
    "babel-preset-es2015": "^6.3.13",
    "babel-register": "^6.5.2",
    "browser-sync": "^2.2.1",
    "del": "^2.2.0",
    "gulp": "^3.9.0",
    "gulp-autoprefixer": "^3.0.1",
    "gulp-babel": "^6.1.1",
    "gulp-cache": "^0.4.2",
    "gulp-cssnano": "^2.0.0",
    "gulp-eslint": "^3.0.0",
    "gulp-filter": "^4.0.0",
    "gulp-htmlmin": "^3.0.0",
    "gulp-if": "^2.0.2",
    "gulp-imagemin": "^3.0.1",
    "gulp-load-plugins": "^1.2.4",
    "gulp-notify": "^3.0.0",
    "gulp-plumber": "^1.0.1",
    "gulp-sass": "^2.0.0",
    "gulp-size": "^2.1.0",
    "gulp-sourcemaps": "^2.2.0",
    "gulp-tinypng": "^1.0.2",
    "gulp-uglify": "^2.0.0",
    "gulp-useref": "^3.0.0",
    "main-bower-files": "^2.5.0",
    "wiredep": "^4.0.0"
  },
  "eslintConfig": {
    "env": {
      "es6": true,
      "node": true,
      "browser": true
    },
    "rules": {
      "quotes": [
        2,
        "single"
      ]
    }
  }
}

来自“npm install”命令的错误:

 fsevents: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance


warning Error running install script for optional dependency: "/Users/kevin/Desktop/Work/Resources/gulp-rapidstart/node_modules/fsevents: Command failed.
Exit code: 1


node-pre-gyp http 404 https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.0.15/fse-v1.0.15-node-v57-darwin-x64.tar.gz
node-pre-gyp ERR! Tried to download(404): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.0.15/fse-v1.0.15-node-v57-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for fsevents@1.0.15 and node@8.11.2 (node-v57 ABI) (falling back to source compile with node-gyp)
node-pre-gyp http 404 status code downloading tarball https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.0.15/fse-v1.0.15-node-v57-darwin-x64.tar.gz


xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance


AttributeError: 'NoneType' object has no attribute 'groups'
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/Users/kevin/Desktop/Work/Resources/gulp-rapidstart/node_modules/node-gyp/lib/configure.js:305: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 Darwin 17.5.0
gyp ERR! command \"/usr/local/bin/node\" \"/Users/kevin/Desktop/Work/Resources/gulp-rapidstart/node_modules/node-gyp/bin/node-gyp.js\" \"configure\" \"--fallback-to-build\" \"--module=/Users/kevin/Desktop/Work/Resources/gulp-rapidstart/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node\" \"--module_name=fse\" \"--module_path=/Users/kevin/Desktop/Work/Resources/gulp-rapidstart/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64\" \"--python=/usr/bin/python\"
gyp ERR! cwd /Users/kevin/Desktop/Work/Resources/gulp-rapidstart/node_modules/fsevents
gyp ERR! node -v v8.11.2
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /Users/kevin/Desktop/Work/Resources/gulp-rapidstart/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/kevin/Desktop/Work/Resources/gulp-rapidstart/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node --module_name=fse --module_path=/Users/kevin/Desktop/Work/Resources/gulp-rapidstart/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64 --python=/usr/bin/python' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/Users/kevin/Desktop/Work/Resources/gulp-rapidstart/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:126:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:214:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:925:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
node-pre-gyp ERR! System Darwin 17.5.0
node-pre-gyp ERR! command \"/usr/local/bin/node\" \"/Users/kevin/Desktop/Work/Resources/gulp-rapidstart/node_modules/fsevents/node_modules/.bin/node-pre-gyp\" \"install\" \"--fallback-to-build\"
node-pre-gyp ERR! cwd /Users/kevin/Desktop/Work/Resources/gulp-rapidstart/node_modules/fsevents
node-pre-gyp ERR! node -v v8.11.2
node-pre-gyp ERR! node-pre-gyp -v v0.6.32

我不确定哪些错误是重要错误,因为在complete log 中有 28 个“错误”字搜索结果

目前我陷入困境,无法解决此问题。

【问题讨论】:

  • 欢迎来到 Stack Overflow!您的问题应直接包含相关的错误消息。否则,如果您使用的粘贴箱服务关闭,问题及其答案将变得对后代无用。
  • 好吧,我不确定哪些错误消息是重要的,因为它们有很多;单词“错误”的 28 个结果
  • 嗯,确实如此。尽管如此,Stack Overflow 并不是一个支持论坛。它是关于为每个普遍感兴趣的编程问题找到可能的最佳答案。也许您想查看有关创建minimal reproducible example 的帮助页面,以了解如何将您的问题转化为符合 Stack Overflow 政策的问题。
  • 我已经编辑了OP,我希望现在是more valid
  • 好多了,谢谢!

标签: node.js macos npm yarnpkg


【解决方案1】:

您需要安装命令行工具。相关链接http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/

更详细的解释here

【讨论】:

    【解决方案2】:

    所以,您可能正在使用 MacO。我的解决方案是安装 XCode。我不知道,但是有一些关于 XCode 依赖关系的东西。

    【讨论】:

      【解决方案3】:

      这对我有用

      npm 安装 -g n n 8.8.1

      sudo npm explore npm -g -- npm install node-gyp@latest

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-05-04
        • 1970-01-01
        • 2014-04-22
        • 2020-05-12
        • 2021-12-16
        • 1970-01-01
        • 1970-01-01
        • 2018-01-25
        相关资源
        最近更新 更多