3

I have the babel cli installed on my machine using:

npm install -g babel-cli

When I run this command I get the desired output. i.e out.js is created

babel script.js --out-file out.js

but when I try to run that command via npm I get an error saying

The CLI has been moved into the package `babel-cli`.

$ npm install -g babel-cli

Here's the package.json:

{
    "name": "youtubeapiloader",
    "version": "1.0.0",
    "main": "index.js",
    "scripts": {
    "compile": "babel -g src/youtube-api-loader.js --out-file   youtube-api.js",
    "prepublish": "npm run compile"
},
    "devDependencies": {
        "babel": "^6.1.18"
    }
}

1 Answer 1

4

Have you tried installing babel-cli as a devDependency already? I managed to get it working like this. Just do

npm install babel-cli --save-dev

Perhaps you might also need babel-core, but I can not remember correctly.

Note that if you want to run this using Travis CI you might still need to globally install babel-cli using a custom installation step within your .travis.yml. e.g.

language: node_js
sudo: false
node_js:
  - "5.0"
install:
  - npm install -g babel-cli
  - npm install
1
  • You can also reference the local babel binary instead of installing it globally: ./node_modules/.bin/babel Commented Jun 15, 2016 at 22:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.