Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm WARN [email protected] requires a peer of babel-core@^6.0.0 but none was installed

Tags:

I am trying to install Babel and two other plugins to use with Webpack and Reactjs.

I used this command :

npm i babel-loader babel-preset-es2015 babel-preset-react -S 

which gives me warning messages :

UNMET PEER DEPENDENCY babel-core@^6.0.0 

and this one :

npm WARN [email protected] requires a peer of babel-core@^6.0.0 but none was installed. 

And an error message :

ERROR in Cannot find module 'babel-core' 

How can I fix this ?

Thanks in advance.

like image 432
Achraf JEDAY Avatar asked Nov 25 '16 12:11

Achraf JEDAY


People also ask

How do I check my Babel version?

You can also check the version of babel-cli by finding the babel-cli folder in node_modules and looking at the version property of the package. json that is at the base of that folder. If babel-cli was installed globally via -g flag of npm install , you could check the version by executing command babel --version .


2 Answers

The reason behind this is that npm deprecated auto-installing of peerDependencies since npm@3, so required peer dependencies like babel-core and webpack must be listed explicitly in your package.json.

All that you need to do is to install babel-core.

like image 161
Cosmin Ababei Avatar answered Oct 01 '22 10:10

Cosmin Ababei


Just added this line:

"babel-core": "^6.0.0", 

to my package.json file (dependency), tried the same command again and the warning message vanished.

EDIT: To get rid of this error:

ERROR in Cannot find module 'babel-core' 

I installed babel-core along with the other plugins using this command:

npm i babel-core babel-loader babel-preset-es2015 babel-preset-react -S 
like image 25
Achraf JEDAY Avatar answered Oct 01 '22 11:10

Achraf JEDAY