【问题标题】:Cannot install tensorflow js无法安装tensorflow js
【发布时间】:2020-06-05 21:25:25
【问题描述】:

我正在尝试安装 tensorflow 依赖项,但在终端控制台中出现错误。

我的 package.json:

{
  "name": "knn-tf",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@tensorflow/tfjs-node": "^0.1.17",
    "lodash": "^4.17.11",
    "shuffle-seed": "^1.1.6"
  }
}

* Building TensorFlow Node.js bindings
/Users/mateusz/WebstormProjects/ML_JS/MLKits/knn-tf/node_modules/@tensorflow/tfjs-node/scripts/install.js:154
      throw new Error('node-gyp rebuild failed with: ' + err);
      ^

Error: node-gyp rebuild failed with: Error: Command failed: node-gyp rebuild
No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.
No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.
No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.



gyp: No Xcode or CLT version detected!
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Darwin 19.5.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/mateusz/WebstormProjects/ML_JS/MLKits/knn-tf/node_modules/@tensorflow/tfjs-node
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v5.0.7
gyp ERR! not ok 

    at /Users/mateusz/WebstormProjects/ML_JS/MLKits/knn-tf/node_modules/@tensorflow/tfjs-node/scripts/install.js:154:13
    at ChildProcess.exithandler (child_process.js:302:5)
    at ChildProcess.emit (events.js:210:5)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
npm WARN knn-tf@1.0.0 No description
npm WARN knn-tf@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @tensorflow/tfjs-node@0.1.21 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @tensorflow/tfjs-node@0.1.21 install 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!     /Users/mateusz/.npm/_logs/2020-06-05T21_16_30_200Z-debug.log

这发生在我运行 npm i

我尝试删除 node_modules 并从头开始安装它,但没有帮助。

您知道如何解决它吗?

【问题讨论】:

    标签: tensorflow npm terminal dependencies


    【解决方案1】:

    一些节点模块正在使用 node-gyp 来编译它们的代码。

    在你的情况下,你使用的是 macos,所以你需要为 macos 安装编译工具。

    您可以通过安装命令行工具来做到这一点。这可以通过执行轻松完成

    xcode-select --install
    

    或从应用商店安装xcode

    安装好命令行工具后,重新运行npm install(之前会建议你删除node_module目录)

    【讨论】:

    • 我已经安装好了。但是,删除 xcode-select 并使用最新版本重新安装会有所帮助。
    猜你喜欢
    • 2018-05-02
    • 2018-09-10
    • 2017-11-04
    • 2018-12-22
    • 2018-11-11
    • 1970-01-01
    • 2020-12-13
    • 2019-01-18
    相关资源
    最近更新 更多