【问题标题】:Could not find plugin "proposal-numeric-separator" in angular app在 Angular 应用程序中找不到插件“proposal-numeric-separator”
【发布时间】:2020-07-02 13:38:30
【问题描述】:

我在运行 ng build --prod 时遇到错误。

An unhandled exception occurred: [BABEL] /root/catch-up-enterprise/dist/polyfills-es5.8e4ba13e1c10f0a37bb4.js: Could not find plugin "proposal-numeric-separator". Ensure there is an entry in ./available-plugins.js for it. (While processing: "/root/catch-up-enterprise/node_modules/@angular-devkit/build-angular/node_modules/@babel/preset-env/lib/index.js") See "/tmp/ng-sg4wHH/angular-errors.log" for further details

错误日志:

[root@localhost ~]# more /tmp/ng-sg4wHH/angular-errors.log
[error] Error: [BABEL] /root/catch-up-enterprise/dist/polyfills-es5.8e4ba13e1c10f0a37bb4.js: Could not find plugin "proposal-numeric-separator". Ensure there is an entry 
in ./available-plugins.js for it. (While processing: "/root/catch-up-enterprise/node_modules/@angular-devkit/build-angular/node_modules/@babel/preset-env/lib/index.js")
    at getPlugin (/root/catch-up-enterprise/node_modules/@angular-devkit/build-angular/node_modules/@babel/preset-env/lib/index.js:67:11)
    at Array.from.map.pluginName (/root/catch-up-enterprise/node_modules/@angular-devkit/build-angular/node_modules/@babel/preset-env/lib/index.js:258:62)
    at Array.map (<anonymous>)
    at _default (/root/catch-up-enterprise/node_modules/@angular-devkit/build-angular/node_modules/@babel/preset-env/lib/index.js:258:43)
    at /root/catch-up-enterprise/node_modules/@babel/helper-plugin-utils/lib/index.js:19:12
    at /root/catch-up-enterprise/node_modules/@babel/core/lib/config/full.js:179:14
    at Generator.next (<anonymous>)
    at Function.<anonymous> (/root/catch-up-enterprise/node_modules/@babel/core/lib/gensync-utils/async.js:26:3)
    at Generator.next (<anonymous>)
    at step (/root/catch-up-enterprise/node_modules/gensync/index.js:254:32)
    at evaluateAsync (/root/catch-up-enterprise/node_modules/gensync/index.js:284:5)
    at Function.errback (/root/catch-up-enterprise/node_modules/gensync/index.js:108:7)
    at errback (/root/catch-up-enterprise/node_modules/@babel/core/lib/gensync-utils/async.js:70:18)
    at async (/root/catch-up-enterprise/node_modules/gensync/index.js:183:31)
    at onFirstPause (/root/catch-up-enterprise/node_modules/gensync/index.js:209:13)
    at Generator.next (<anonymous>)

尝试的步骤: 我认为问题是缺少proposal-numeric-separator模块,所以通过下面的命令安装了模块

    npm i @babel/plugin-proposal-numeric-separator

问题还是没有解决,所以尝试了similar issue给出的答案,还是出现了同样的错误。

如何解决这个问题?

【问题讨论】:

    标签: angular npm


    【解决方案1】:

    感谢issue8680的nicolo-ribaudo

    添加依赖 @babel/compat-data": "7.8.0" 为我解决了这个问题。

    vi package.json
    
        "dependencies": {
            "@babel/compat-data": "7.8.0",
            ...
        }
    
    npm install
    
    ng build --prod
    

    【讨论】:

    • 添加依赖后别忘了运行npm i
    【解决方案2】:

    对我有用

    第 1 步:在你的 devDependencies 中添加:“@babel/compat-data”:“7.8.0

    第 2 步:运行 - npm install

    【讨论】:

      猜你喜欢
      • 2020-07-01
      • 2020-07-16
      • 2020-07-02
      • 2020-07-07
      • 2022-06-12
      • 2020-10-16
      • 2021-05-23
      • 2016-07-23
      • 1970-01-01
      相关资源
      最近更新 更多