首页 > 解决方案 > 为什么在项目中导入 tensorflow js 时会出错

问题描述

仅导入 tensorflow 库甚至不使用其方法时,我收到以下错误。这是错误:

./node_modules/@tensorflow/tfjs-core/dist/io/http.js 错误:/Users/smok/My Projects/Visual/node_modules/@tensorflow/tfjs-core/dist/io/http.js:预期类型“带有未定义选项的表达式”,而是得到了“SpreadElement”。在 Array.map () 在 Array.forEach ()

这是我的 package.json:

  "name": "mdbreact-admin-pro",
  "version": "4.25.0",
  "private": true,
  "dependencies": {
    "@babel/core": "^7.16.0",
    "@babel/preset-env": "^7.16.0",
    "@material-ui/core": "^4.12.3",
    "@mediapipe/camera_utils": "^0.3.1632432234",
    "@mediapipe/control_utils": "^0.6.1629159505",
    "@mediapipe/drawing_utils": "^0.3.1620248257",
    "@mediapipe/face_detection": "^0.4.1628005423",
    "@mediapipe/selfie_segmentation": "^0.1.1632777926",
    "@szhsin/react-menu": "^2.0.1",
    "@tensorflow-models/body-pix": "^2.0.5",
    "@tensorflow/tfjs": "^2.4.0",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "@toast-ui/react-image-editor": "^3.15.0",
    "apexcharts": "^3.26.0",
    "axios": "^0.19.2",
    "babel-core": "^6.26.0",
    "babel-preset-env": "^1.6.1",
    "capture-frame": "^4.0.0",
    "chroma-js": "^2.1.2",
    "draft-js": "^0.10.5",
    "event-source-polyfill": "^1.0.22",
    "google-map-react": "^1.1.0",
    "jalali-date": "^1.1.1",
    "jalali-moment": "^3.3.10",
    "mdbreact": "./mdbreact-4.25.0.tgz",
    "node-fetch": "^2.6.1",
    "react": "17.0.2",
    "react-apexcharts": "^1.3.7",
    "react-big-calendar": "^0.20.2",
    "react-canvas-draw": "^1.1.1",
    "react-compare-image": "^3.1.0",
    "react-confirm-alert": "^2.7.0",
    "react-dom": "17.0.2",
    "react-draft-wysiwyg": "^1.13.2",
    "react-hook-form": "^7.6.6",
    "react-hot-toast": "^2.0.0",
    "react-image-crop": "^8.6.12",
    "react-image-size": "^1.0.4",
    "react-interval-hook": "^1.1.3",
    "react-jvectormap": "^0.0.4",
    "react-modern-calendar-datepicker": "^3.1.6",
    "react-redux": "^7.2.5",
    "react-router": "^5.1.2",
    "react-router-dom": "^5.3.0",
    "react-scripts": "3.4.3",
    "react-switch": "^6.0.0",
    "react-thermometer-component": "^1.0.1",
    "react-toastify": "^8.0.3",
    "react-tooltip": "^4.2.21",
    "react-webcam": "^5.2.4",
    "reactjs-media": "^1.5.1",
    "redux": "^4.0.5",
    "redux-mock-store": "^1.5.4",
    "redux-promise-middleware": "^6.1.2",
    "s": "^1.0.0",
    "sass": "^1.36.0",
    "tui-color-picker": "^2.2.7"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]
}

标签: reactjstensorflow.js

解决方案


推荐阅读