Using Babel Kli

Is there a way to use the babel client without installing it around the world?

So instead

npm install -g babel-cli 

I would like to do it

 npm install babel-cli --save-dev 
+8
javascript npm babeljs
source share
3 answers

Any local batch binary can be obtained in npm scripts , as if it were installed globally:

 // package.json { "scripts": { "build": "babel ..." } } 

If you want to execute binary on the command line, you can use the relative path to node_modules/.bin/ :

 $ node_modules/.bin/babel ... 

This is due to the first example: node_modules/.bin/ simply added to the PATH of the environment in which npm scripts are executed.

+14
source share

you can add something like this:

 { "scripts": { "start": "babel-node test.js" } } 

in package.json where test.js is the script you want to run. Now you can start it with the npm start command

+2
source share

Yes, you can install locally and run with node_modules :

 ./node_modules/.bin/babel 

If you have a local package package.json, you can add an NPM script to simplify this command, since NPM scripts work with ./node_modules/.bin on PATH :

 "scripts": { "babel": "babel ...", } 

To run from any directory in package.json:

 $ npm run babel 
0
source share

All Articles