99

How to fix Could not find plugin "proposal-numeric-separator", I get this error when I try to build my React application, I have not ejected the application yet:

./src/index.js
Error: [BABEL] /home/pc/Downloads/project/src/index.js: Could not find plugin "proposal-numeric-separator". Ensure there is an entry in ./available-plugins.js for it. (While processing: "/home/pc/Downloads/project/node_modules/babel-preset-react-app/index.js$0")
    at Array.map (<anonymous>)
    at Generator.next (<anonymous>)
    at Generator.next (<anonymous>)


error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I have tried to download Babel and the dependency Proposal Numeric Separator, remove the Node Modules, clean the Yarn cache; but nothing worked.

I'm using Yarn 1.22.4 and Node 13.11.0, but I have also tried with NPM 6.13.7.

Bernard Vander Beken
  • 4,848
  • 5
  • 54
  • 76

18 Answers18

92

The following steps work:

  1. Add the following line to package.json:
"resolutions": { 
  "@babel/preset-env": "7.5.5" 
},
  1. Run the following command:
$ npx npm-force-resolutions
  1. Install dependencies:
$ npm install
# or 
$ yarn
  1. Build your project:
$ yarn build

Take a look at this Github Issue

glinda93
  • 7,659
  • 5
  • 40
  • 78
Hillkim Henry
  • 2,841
  • 13
  • 17
  • 2
    Just added `resolutions`, removed *node_modules* and installed the dependencies. It worked, thanks. **Observation**: I have tested the build and everything is ok. –  Mar 20 '20 at 21:48
  • 2
    man, you save my life. How do you know about this answer? You have got my awesome like, buddy. Thanks a lot. – Carlos Querioz Mar 21 '20 at 00:35
  • 1
    @CarlosQuerioz I think that the reason is the last topic from [this](https://classic.yarnpkg.com/en/docs/selective-version-resolutions/#toc-why-would-you-want-to-do-this) documentation: "Your dependency defines a broad version range and your sub-dependency just got a problematic update so you want to pin it to an earlier version" –  Mar 21 '20 at 01:40
  • 1
    Thank you man. I don't know what happened. How does it happen suddenly. I coul build it normally until yesterday and today I had to do this to fix it? – user3746480 Apr 10 '20 at 11:37
  • 2
    @user3746480 It is a problem with the babel dependencies. The most probable cause might be removing or updating node modules. Thats why enforcing a given working version fixes it – Hillkim Henry Apr 10 '20 at 22:41
  • awsome, in my case, after running audit fix command ran into this issue thanks for a day, be careful guys while running such command while it may be essential but at the cost of a day – Naga Aug 07 '20 at 21:08
62

Try this, it works: npm i @babel/compat-data@7.8.0

I have just used it like 10 minutes ago, and it's working fine.

Related issue going on github about this. Click Here!

Wahab Shah
  • 2,066
  • 1
  • 14
  • 19
16

From the corresponding issue in create-react-app,

Update react-scripts to 3.4.1 in your package.json file and remove node_modules as well as package-lock.json/yarn.lock and re-install.

jobinbasani
  • 2,075
  • 6
  • 47
  • 66
15

Why this problem happened?:

It's an issue of conflicts between internal packages used by babel.

Adding a new plugin to @babel/compat-data breaks old @babel/preset-env versions. This is because preset-env iterates over compat-data's plugins, and throws if the plugin isn't defined in preset-env's available-plugins.js file.

This is the merge that fixed the issue: https://github.com/babel/babel/pull/11201/files/a88a00750c61ff89f1622d408d67108719f21ecd

Solution:

  • Delete package-lock.json or yarn.lock
  • Delete node_modules folder
  • In package.jon I have adjusted the version numbers of these packages to:
    ...
    "devDependencies": {
        "@babel/compat-data": "^7.8.0",
        "@babel/preset-env": "^7.8.0",
        "babel-loader": "^8.1.0",
        ...
    },
    ...
    "resolutions": {
        "@babel/preset-env": "^7.8.0"
    }
  • Run npm install
  • Run npm run build
Badis Merabet
  • 13,970
  • 9
  • 40
  • 55
9

Reference: https://github.com/angular/angular-cli/issues/17262

I found two solution

a ) Install babel compat

"devDependencies": {
    "@babel/compat-data": "7.8.0",
} 

b) Install plugin-proposal-numeric-separator

npm install --save-dev @babel/plugin-proposal-numeric-separator

install this version only 7.8.0

  1. Angular CLI can create this kind of issue. Go to package json and change it to

    build-angular": "0.803.17"

please don't add ^ or ~ .

Gajender Singh
  • 1,285
  • 14
  • 13
7

I faced similar issue and i was able to fix it by updating all babel dependencies to latest version. I'm not aware of the exact issue with babel. However, the below mentioned step worked for me.

Step 1: identify and remove all babel related dependencies from package.json

npm remove @babel/runtime @babel/core @babel/plugin-proposal-class-properties @babel/plugin-transform-modules-commonjs @babel/plugin-transform-runtime @babel/preset-env @babel/preset-react babel-eslint babel-jest babel-loader

Step 2: re-install babel dependencies

npm install --save @babel/runtime

npm install --save-dev @babel/core @babel/plugin-proposal-class-properties @babel/plugin-transform-modules-commonjs @babel/plugin-transform-runtime @babel/preset-env @babel/preset-react babel-eslint babel-jest babel-loader

PS: The above list of babel dependencies will differ for your project.

7

I just changed react-script version from 3.0.1 to 3.4.1

7

You can use this command, which has worked for me.

npm i @babel/compat-data@7.8.0
Dharman
  • 30,962
  • 25
  • 85
  • 135
M Danial
  • 166
  • 1
  • 4
5

I'm using angular & this worked for me, simply changed the version of @babel/compat-data from ^7.8.0 to just 7.8.0, the package-lock.json is having newer version which has bugs.

Inside package.json:

  "devDependencies": {
    "@babel/compat-data": "7.8.0",
}
Furqan S. Mahmoud
  • 1,417
  • 2
  • 13
  • 26
5

In package.json

  "dependencies": {
    "@babel/compat-data": "7.8.0",
    "@babel/plugin-proposal-numeric-separator": "^7.8.3",
    "babel-loader": "^8.1.0",
  ....
  "resolutions": {
     "@babel/preset-env": "^7.8.7"
  }

it is working for me. You can read more

https://github.com/angular/angular-cli/issues/17262#issuecomment-603396857

Gerardo Perrucci
  • 704
  • 7
  • 13
4

Its just a 4 step process.

Reason: This happens because of a package missing in babel. This will happen even if you create angular app using ng new command.

Solution

  1. Install plugin-proposal-numeric-separator using the following code in terminal.

    npm install --save @babel/plugin-proposal-numeric-separator
    
  2. Once it is done navigate to the file as shown below.

    node_modules > @babel > preset-env > available-plugins.js

  3. In available-plugins.js below exports.default = void 0; copy and paste the following code.

    var _pluginProposalNumericSeparator = _interopRequireDefault(require("@babel/plugin-proposal-numeric-separator"));
    
  4. In available-plugins.js within var _default object declaration copy and paste the following code.

    "proposal-numeric-separator": _pluginProposalNumericSeparator.default,
    

And it is done.

Ajith CR
  • 89
  • 4
  • I think that is not a valid solution, please follow this thread: https://stackoverflow.com/questions/60780664/could-not-find-plugin-proposal-numeric-separator/60892324#60892324 – Gerardo Perrucci Mar 27 '20 at 18:46
4

In my angular 8 application, although I did not have any direct dependancy of react-scripts package and did not have it in package.json either but started getting this error on build. It was likely used as a depedancy by other packges.

By reading this post on github, I added it as dependancy in package.json "react-scripts": "3.4.1" and run npm install the build started working just fine.

rumi
  • 3,293
  • 12
  • 68
  • 109
4

This worked for me:

  • Delete package-lock.json
  • Delete node_modules
  • Run npm i
Eric Eskildsen
  • 4,269
  • 2
  • 38
  • 55
1

try this , this working with me .

npm i @babel/compat-data@7.8.0
Abd Abughazaleh
  • 4,615
  • 3
  • 44
  • 53
0

Add SKIP_PREFLIGHT_CHECK=true to .env file to make the build work without ejecting and follow the below steps:

  • Delete node_modules and package-lock.json
  • Add "resolutions": { "@babel/preset-env": "^7.8.7" } to package.json
  • Run npm install npm-force-resolutions --save-dev
  • Run npm install
  • Run npx npm-force-resolutions
  • Run npm install again
  • Run npm run build
Zameer Ansari
  • 28,977
  • 24
  • 140
  • 219
0

In my case I've got a corrupted node_modules folder. My yarn install simply stopped in the middle by a power surge.

By running:

rm -rf node_modules
yarn

My problem was solved.

Christian Saiki
  • 1,568
  • 15
  • 22
0

worked for me. npm install @babel/compat-data@~7.8.0

Ankur Garg
  • 151
  • 2
  • 2
-2

I just had this happen to me. The To fix it I ran yarn build with sudo privileges.

Noah Cote
  • 23
  • 1
  • 2