【问题标题】:Ionic android build fails with Could not find plugin "proposal-numeric-separator"Ionic android 构建失败,找不到插件“proposal-numeric-separator”
【发布时间】:2020-07-02 08:50:11
【问题描述】:

我的应用在浏览器中运行良好,并在我启动 android 构建时使用 Cordova Geolocation 作为插件我收到此错误

An unhandled exception occurred: [BABEL] /Users/suatkarabacak/Desktop/quarantine/www/2-es2015.js: Could not find plugin "proposal-numeric-separator". Ensure there is an entry in ./available-plugins.js for it. (While processing: "/Users/suatkarabacak/Desktop/quarantine/node_modules/@babel/preset-env/lib/index.js")
See "/private/var/folders/2n/czcjwx7554j_h2hpsj53h81m0000gn/T/ng-ZxzGC4/angular-errors.log" for further details.
[ERROR] An error occurred while running subprocess ng.

来自 package-lock.json

"@babel/preset-env": {
      "version": "7.8.3",
      "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.8.3.tgz",
      "integrity": "sha512-Rs4RPL2KjSLSE2mWAx5/iCH+GC1ikKdxPrhnRS6PfFVaiZeom22VFKN4X8ZthyN61kAaR05tfXTbCvatl9WIQg==",
      "dev": true,
      "requires": {
        "@babel/compat-data": "^7.8.0",
        "@babel/helper-compilation-targets": "^7.8.3",
        "@babel/helper-module-imports": "^7.8.3",
        "@babel/helper-plugin-utils": "^7.8.3",
        "@babel/plugin-proposal-async-generator-functions": "^7.8.3",
        "@babel/plugin-proposal-dynamic-import": "^7.8.3",
        "@babel/plugin-proposal-json-strings": "^7.8.3",
        "@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.3",
        "@babel/plugin-proposal-object-rest-spread": "^7.8.3",
        "@babel/plugin-proposal-optional-catch-binding": "^7.8.3",
        "@babel/plugin-proposal-optional-chaining": "^7.8.3",
        "@babel/plugin-proposal-unicode-property-regex": "^7.8.3",
        "@babel/plugin-syntax-async-generators": "^7.8.0",
        "@babel/plugin-syntax-dynamic-import": "^7.8.0",
        "@babel/plugin-syntax-json-strings": "^7.8.0",
        "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.0",
        "@babel/plugin-syntax-object-rest-spread": "^7.8.0",
        "@babel/plugin-syntax-optional-catch-binding": "^7.8.0",
        "@babel/plugin-syntax-optional-chaining": "^7.8.0",
        "@babel/plugin-syntax-top-level-await": "^7.8.3",
        "@babel/plugin-transform-arrow-functions": "^7.8.3",
        "@babel/plugin-transform-async-to-generator": "^7.8.3",
        "@babel/plugin-transform-block-scoped-functions": "^7.8.3",
        "@babel/plugin-transform-block-scoping": "^7.8.3",
        "@babel/plugin-transform-classes": "^7.8.3",
        "@babel/plugin-transform-computed-properties": "^7.8.3",
        "@babel/plugin-transform-destructuring": "^7.8.3",
        "@babel/plugin-transform-dotall-regex": "^7.8.3",
        "@babel/plugin-transform-duplicate-keys": "^7.8.3",
        "@babel/plugin-transform-exponentiation-operator": "^7.8.3",
        "@babel/plugin-transform-for-of": "^7.8.3",
        "@babel/plugin-transform-function-name": "^7.8.3",
        "@babel/plugin-transform-literals": "^7.8.3",
        "@babel/plugin-transform-member-expression-literals": "^7.8.3",
        "@babel/plugin-transform-modules-amd": "^7.8.3",
        "@babel/plugin-transform-modules-commonjs": "^7.8.3",
        "@babel/plugin-transform-modules-systemjs": "^7.8.3",
        "@babel/plugin-transform-modules-umd": "^7.8.3",
        "@babel/plugin-transform-named-capturing-groups-regex": "^7.8.3",
        "@babel/plugin-transform-new-target": "^7.8.3",
        "@babel/plugin-transform-object-super": "^7.8.3",
        "@babel/plugin-transform-parameters": "^7.8.3",
        "@babel/plugin-transform-property-literals": "^7.8.3",
        "@babel/plugin-transform-regenerator": "^7.8.3",
        "@babel/plugin-transform-reserved-words": "^7.8.3",
        "@babel/plugin-transform-shorthand-properties": "^7.8.3",
        "@babel/plugin-transform-spread": "^7.8.3",
        "@babel/plugin-transform-sticky-regex": "^7.8.3",
        "@babel/plugin-transform-template-literals": "^7.8.3",
        "@babel/plugin-transform-typeof-symbol": "^7.8.3",
        "@babel/plugin-transform-unicode-regex": "^7.8.3",
        "@babel/types": "^7.8.3",
        "browserslist": "^4.8.2",
        "core-js-compat": "^3.6.2",
        "invariant": "^2.2.2",
        "levenary": "^1.1.0",
        "semver": "^5.5.0"
      }

尝试更改 babel 的版本,但也无济于事。我收到太多关于问题错误的代码,但我不知道是否需要任何其他解释,所以我正在写这句话。

【问题讨论】:

    标签: android cordova ionic-framework cordova-plugins babeljs


    【解决方案1】:

    这就是我修复完全相同的异常的方法:

    1-打开package.json并添加

     "resolutions": {
      "@babel/preset-env": "^7.8.7"
     },
    
     "dependencies": {..}
    

    2-运行npx npm-force-resolutions

    3-运行npm install

    现在你可以开始了..

    【讨论】:

    • 无法尝试,因为我已经解决了,但如果有人可以尝试并批准该解决方案,我将标记为答案。
    • @SuatKarabacak 你是如何解决这个问题的?我已经尝试了所有选项,但没有一个对我有用
    • 我用我的答案解决了stackoverflow.com/a/60787422/5229886
    【解决方案2】:

    更改您的 tsconfig.json 文件目标值

    表格 { “目标”:“es2015” } 到 { “目标”:“es5” }

    这对我有用。

    【讨论】:

      【解决方案3】:

      经过几次尝试:

      1. 安装npm i @babel/plugin-proposal-numeric-separator
      2. 转到node_modules/@babel/preset-env/lib/available-plugins.js
      3. 添加var _pluginTransformNumericSeperator = _interopRequireDefault(require("@babel/plugin-proposal-numeric-separator"));
      4. 并将"proposal-numeric-separator": _pluginTransformNumericSeperator 添加到默认变量中

      【讨论】:

      • 这不是一个好方法。你不应该修改 node_modules 依赖项
      • 这是一种解决方法,但是在互联网上研究了许多解决方案后,它对我有用。
      • 这不是一个好方法,因为如果作者更新包,那么当你进行 npm 更新时,你的更改将被覆盖。正确的做法是克隆 git 存储库,进行更改并在项目中使用克隆。
      猜你喜欢
      • 2020-07-01
      • 2020-07-16
      • 2020-07-02
      • 2020-07-07
      • 2016-07-12
      • 1970-01-01
      • 2018-11-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多