NervJS / taro

开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5/React Native 等应用。 https://taro.zone/
https://docs.taro.zone/
Other
35.52k stars 4.79k forks source link

启动报错,全部重新安装后依然无效,版本3.0.14 #14498

Closed moyupoi closed 1 year ago

moyupoi commented 1 year ago

相关平台

H5

浏览器版本: 116.0.5845.140 使用框架: React

复现步骤

yarn dev:h5 启动报错

Error: Cannot find module '@babel/plugin-syntax-import-assertions'
Require stack:
- /Users/classic/.config/yarn/global/node_modules/@tarojs/helper/node_modules/@babel/preset-env/lib/available-plugins.js
- /Users/classic/.config/yarn/global/node_modules/@tarojs/helper/node_modules/@babel/preset-env/lib/filter-items.js
- /Users/classic/.config/yarn/global/node_modules/@tarojs/helper/node_modules/@babel/preset-env/lib/index.js
- /Users/classic/.config/yarn/global/node_modules/@tarojs/helper/node_modules/@babel/core/lib/config/files/plugins.js
- /Users/classic/.config/yarn/global/node_modules/@tarojs/helper/node_modules/@babel/core/lib/config/files/index.js
- /Users/classic/.config/yarn/global/node_modules/@tarojs/helper/node_modules/@babel/core/lib/index.js
- /Users/classic/.config/yarn/global/node_modules/@tarojs/helper/node_modules/@babel/register/lib/cache.js
- /Users/classic/.config/yarn/global/node_modules/@tarojs/helper/node_modules/@babel/register/lib/node.js
- /Users/classic/.config/yarn/global/node_modules/@tarojs/helper/node_modules/@babel/register/lib/index.js
- /Users/classic/.config/yarn/global/node_modules/@tarojs/helper/dist/babelRegister.js
- /Users/classic/.config/yarn/global/node_modules/@tarojs/helper/dist/utils.js
- /Users/classic/.config/yarn/global/node_modules/@tarojs/helper/dist/index.js
- /Users/classic/.config/yarn/global/node_modules/@tarojs/helper/index.js
- /Users/classic/.config/yarn/global/node_modules/@tarojs/cli/dist/util/index.js
- /Users/classic/.config/yarn/global/node_modules/@tarojs/cli/bin/taro

期望结果

公司的老项目,以前可以启动,taro-cli重新安装3.0.14和项目中的版本对上的,项目也是一直用3.0.14,今日尝试启动发现启动报错找不到@babel/plugin-syntax-import-assertions,安装@babel/plugin-syntax-import-assertions后依然无效

实际结果

期望能正常启动,辛苦帮忙看下

环境信息

👽 Taro v3.0.14 
  Taro CLI 3.0.14 environment info:
    System:
      OS: mac 13.3.1 
    Binaries:
      Node: v14.18.0 -
      Yarn: 1.22.4 -
      npm: 9.4.1 -
    npmPackages:
     报错,以上信息手动补充

补充信息

"dependencies": {
        "@babel/plugin-syntax-import-assertions": "^7.22.5",
        "@babel/runtime": "^7.7.7",
        "@tarojs/components": "3.0.14",
        "@tarojs/react": "3.0.14",
        "@tarojs/runtime": "3.0.14",
        "@tarojs/taro": "3.0.14",
        "@uiw/react-baidu-map": "^1.17.1",
        "antd-mobile": "^2.3.3",
        "css-loader": "^4.2.1",
        "dart-sass": "^1.25.0",
        "dva-core": "^2.0.2",
        "dva-loading": "^3.0.20",
        "jspdf": "^2.1.1",
        "mockjs": "^1.1.0",
        "nervjs": "^1.5.7",
        "react": "^16.10.0",
        "react-canvas-draw": "^1.1.1",
        "react-dom": "^16.10.0",
        "react-redux": "^7.2.0",
        "redux": "^4.0.0",
        "redux-logger": "^3.0.6",
        "redux-thunk": "^2.3.0",
        "sass-loader": "^9.0.3",
        "style-loader": "^1.2.1",
        "taro-ui": "^3.0.0-alpha.3",
        "terser": "^5.0.0"
    },
    "devDependencies": {
        "@babel/core": "^7.10.4",
        "@tarojs/mini-runner": "3.0.14",
        "@tarojs/webpack-runner": "3.0.14",
        "@types/react": "^16.0.0",
        "@types/webpack-env": "^1.13.6",
        "babel-jest": "^26.1.0",
        "babel-preset-taro": "3.0.14",
        "cross-env": "^7.0.2",
        "eslint": "^6.8.0",
        "eslint-config-taro": "3.0.14",
        "eslint-plugin-import": "^2.12.0",
        "eslint-plugin-react": "^7.8.2",
        "eslint-plugin-react-hooks": "^1.6.1",
        "stylelint": "9.3.0",
        "terser-webpack-plugin": "^4.0.0",
        "webpack-bundle-analyzer": "^3.8.0"
    }
yoyo837 commented 1 year ago

能自行安装一下跳过吗?

moyupoi commented 1 year ago

怎么跳过?yarn global add @tarojs/cli@v3.0.14很多次了,安装好后taro info就报这个错,感觉是这个版本的问题

yoyo837 commented 1 year ago

提示找不到的这个呀 安装一下 @babel/plugin-syntax-import-assertions

moyupoi commented 1 year ago

Contributor 执行过@babel/plugin-syntax-import-assertions,单独安装后依然无效

yoyo837 commented 1 year ago

安装后报什么错

moyupoi commented 1 year ago

知道是怎么回事了,yarn global add @tarojs/cli@v3.0.14这样做是覆盖不了之前的版本的,必须要先remove掉这个全局版本之后再次add才可以,也就是说add并没有把版本库全部清除后覆盖,没关系已经解决了谢谢

moyupoi commented 1 year ago

yarn global add @tarojs/cli@latest yarn global add @tarojs/cli@v3.0.14 这样就会报错 必须要先remove yarn global add @tarojs/cli@latest yarn remove global add @tarojs/cli@latest yarn global add @tarojs/cli@v3.0.14 这样才可以,记录一下

yoyo837 commented 1 year ago

那先关闭咯!