Babel CLI is extremely slow

So, I follow the installation here , but babel takes a very long time to compile even small files:

app.js

let app = 1; 

.babelrc

 { "presets": ["es2015"] } 

package.json

 "scripts": { "build": "babel app.js -o dist/app.js" }, "devDependencies": { "babel-cli": "^6.4.5", "babel-preset-es2015": "^6.3.13" } 

Then npm run build will take ~ 30 seconds to compile.

I am using npm@3.3.12

+10
ecmascript-6 npm babeljs
source share
2 answers

Perhaps you are also compiling node_modules and bower_components .

You can try adding the ignore property to your .babelrc projects as follows:

 { ... "ignore": /(node_modules|bower_components)/ ... } 

Hope this solves your problem.

+2
source share

September 2019 update

The found update to Babel 7 solved this problem. Perhaps try:

 $ npm install --save-dev @babel/core @babel/node @babel/preset-env 

Your package.json should contain something like:

  "devDependencies": { "@babel/core": "^7.6.0", "@babel/node": "^7.6.1", "@babel/preset-env": "^7.6.0" } 

My .babelrc file looks like this:

 { "presets": ["@babel/preset-env"] } 

Now that I am running:

 npx babel-node src/index.js 

the performance is almost instantaneous (it took 20+ seconds for it with babel 6).

See babel 7.5 docs for more on this.

Also, for help on upgrading, see this stack processing & answer question .

0
source share

All Articles