【问题标题】:Strange NPM error on Windows 10Windows 10 上奇怪的 NPM 错误
【发布时间】:2018-01-07 06:02:09
【问题描述】:

在用股票react-native 设置自己并开始切换到打字稿后,我去了yarn install,我得到了

> yarn install v1.3.2
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.1.3: The platform "win32" is incompatible with this module.
info "fsevents@1.1.3" is an optional dependency and failed compatibility 

check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > babel-jest@22.0.4" has unmet peer dependency "babel-core@^6.0.0 || ^7.0.0-0".
[4/4] Building fresh packages...
[1/1] ⢀ weak: Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
[-/1] ⢀ waiting...
[-/1] ⢀ waiting...
[-/1] ⢀ waiting...
warning Error running install script for optional dependency: "C:\\Users\\me\\projects\\mycrate\\node_modules\\weak: Command failed.\nExit code: 1\nCommand: node-gyp rebuild\nArguments: \nDirectory: C:\\Users\\me\\projects\\mycrate\\node_modules\\weak\nOutput:\nC:\\Users\\me\\projects\\mycrate\\node_modules\\weak>if not defined npm_config_node_gyp (node \"C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\node-gyp-bin\\\\..\\..\\node_modules\\node-gyp\\bin\\node-gyp.js\" rebuild )  else (node \"\" rebuild ) \r\ngyp info it worked if it ends with ok\ngyp info using node-gyp@3.6.2\ngyp info using node@9.3.0 | win32 | x64\ngyp info spawn C:\\Python27\\python.EXE\ngyp info spawn args [ 'C:\\\\Program Files\\\\nodejs\\\\node_modules\\\\npm\\\\node_modules\\\\node-gyp\\\\gyp\\\\gyp_main.py',\ngyp info spawn args   'binding.gyp',\ngyp info spawn args   '-f',\ngyp info spawn args   'msvs',\ngyp info spawn args   '-G',\ngyp info spawn args   'msvs_version=auto',\ngyp info spawn args   '-I',\ngyp info spawn args   'C:\\\\Users\\\\me\\\\projects\\\\mycrate\\\\node_modules\\\\weak\\\\build\\\\config.gypi',\ngyp info spawn args   '-I',\ngyp info spawn args   'C:\\\\Program Files\\\\nodejs\\\\node_modules\\\\npm\\\\node_modules\\\\node-gyp\\\\addon.gypi',\ngyp info spawn args   '-I',\ngyp info spawn args   'C:\\\\Users\\\\me\\\\.node-gyp\\\\9.3.0\\\\include\\\\node\\\\common.gypi',\ngyp info spawn args   '-Dlibrary=shared_library',\ngyp info spawn args   '-Dvisibility=default',\ngyp info spawn args   '-Dnode_root_dir=C:\\\\Users\\\\me\\\\.node-gyp\\\\9.3.0',\ngyp info spawn args   '-Dnode_gyp_dir=C:\\\\Program Files\\\\nodejs\\\\node_modules\\\\npm\\\\node_modules\\\\node-gyp',\ngyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\me\\\\.node-gyp\\\\9.3.0\\\\<(target_arch)\\\\node.lib',\ngyp info spawn args   '-Dmodule_root_dir=C:\\\\Users\\\\me\\\\projects\\\\mycrate\\\\node_modules\\\\weak',\ngyp info spawn args   '-Dnode_engine=v8',\ngyp info spawn args   '--depth=.',\ngyp info spawn args   '--no-parallel',\ngyp info spawn args   '--generator-output',\ngyp info spawn args   'C:\\\\Users\\\\me\\\\projects\\\\mycrate\\\\node_modules\\\\weak\\\\build',\ngyp info spawn args   '-Goutput_dir=.' ]\ngyp info spawn C:\\Program Files (x86)\\MSBuild\\14.0\\bin\\msbuild.exe\ngyp info spawn args [ 'build/binding.sln',\ngyp info spawn args   '/clp:Verbosity=minimal',\ngyp info spawn args   '/nologo',\ngyp info spawn args   '/p:Configuration=Release;Platform=x64' ]\nBuilding the projects in this solution one at a time. To enable parallel build, please add the \"/m\" switch.\r\nMSBUILD : error MSB4132: The tools version \"2.0\" is unrecognized. Available tools versions are \"12.0\", \"14.0\", \"4.0\".\r\ngyp ERR! build error \ngyp ERR! stack Error: `C:\\Program Files (x86)\\MSBuild\\14.0\\bin\\msbuild.exe` failed with exit code: 1\ngyp ERR! stack     at ChildProcess.onExit (C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\lib\\build.js:258:23)\ngyp ERR!Done in 7.68s.

相关错误似乎是:

error MSB4132: The tools version \"2.0\" is unrecognized. Available tools versions are \"12.0\", \"14.0\", \"4.0\".\r\ngyp ERR! build error \ngyp ERR! stack Error:

在此之后,我尝试了一些方法:

  • 安装独立的构建工具
  • 尝试在管理 shell 中使用 npm install --production windows-build-tools --global 来 npm install windows-build-tools 包
  • 正在尝试使用 npm config set msvs_version 201x --global 设置要在 npm 中使用的 msvc 版本。其中x 是3、5 或7。

这些都不起作用。

我不知道该怎么做,“只使用 mac 或 linux 机器”目前不是一个选项。

编辑:

我的包依赖是:

  "dependencies": {
    "react": "16.0.0",
    "react-native": "0.51.0"
  },
  "devDependencies": {
    "@types/jest": "^22.0.1",
    "@types/react": "^16.0.34",
    "@types/react-native": "^0.51.9",
    "babel-jest": "22.0.4",
    "babel-preset-react-native": "4.0.0",
    "concurrently": "^3.5.1",
    "jest": "22.0.4",
    "react-test-renderer": "16.0.0",
    "rimraf": "^2.6.2",
    "tslint": "^5.8.0",
    "typescript": "^2.6.2"
  },

再次编辑:

我忘了提到我确实关闭并重新打开了每个步骤的命令行。

【问题讨论】:

    标签: node.js windows npm windows-10 build-tools


    【解决方案1】:

    这可能是您使用的 npm 版本的错误。

    看到这个帖子:

    https://github.com/npm/npm/issues/18380

    尝试将您的 npm 版本回滚到 5.3

    这个问题似乎是带有 babel 包的 windows 独有的。

    【讨论】:

      猜你喜欢
      • 2011-01-27
      • 2016-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-16
      • 1970-01-01
      • 2019-07-07
      • 1970-01-01
      相关资源
      最近更新 更多