带有yarn的Vue / Webpack项目中的tfjs的“找不到依赖项”

时间:2019-04-28 18:48:28

标签: javascript tensorflow vue.js webpack

我正在尝试将TensorFlow.js用于JavaScript项目中的数组操作。我正在使用import * as tf from '@tensorflow/tfjs';

将其导入Vue组件中

看来yarn install tensorflow需要Python 2.7,所以我改用yarn add tensorflow/tfjs安装所需的Tensorflow.js的子集。这似乎有效,但是当我完成yarn run serve时,我收到了以下消息:

 ERROR  Failed to compile with 1 errors

This dependency was not found:

* @tensorflow/tfjs in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/DetectorPlot.vue?vue&type=script&lang=js&

To install it, you can run: npm install --save @tensorflow/tfjs

yarn.lock之后的yarn add tensorflow/tfjs中,我看到:


"@tensorflow/tfjs@github:tensorflow/tfjs":
  version "1.1.0"
  resolved "https://codeload.github.com/tensorflow/tfjs/tar.gz/74b4edef368aa39decc6073af735f81d112bafd8"
  dependencies:
    "@tensorflow/tfjs-converter" "1.1.0"
    "@tensorflow/tfjs-core" "1.1.0"
    "@tensorflow/tfjs-data" "1.1.0"
    "@tensorflow/tfjs-layers" "1.1.0"

1 个答案:

答案 0 :(得分:0)

感谢朋友,我有一个解决方法:

yarn remove @tensorflow/tfjs

yarn add @tensorflow/tfjs

我猜它在第一次尝试安装tensorflow失败时进入了一个奇怪的状态。 (令人沮丧的答案是“关闭并重新打开”的频率)...