0

I am using babel to build a part of my library and I'm running into issues when i run babel commands through npm.

I have an npm script called build that calls:

{
  "prebuild": "rm -rf && mkdir dist",
  "build": "babel src/index.js -o dist/index.js"
}

I have run the actual babel command itself in my command line and it works.

However when I do npm run build from my command line it says

The CLI has been moved into the package 'babel-cli'

npm also says that it is that specific line that is failing.

I have already tried the following:

  1. Restart my terminal.
  2. Install babel v5 because I read that v6 split a lot of its functionality.
  3. npm rebuild.
  4. Delete my node_modules and npm install

Any other ideas? as to why npm fails at running this command?

5
  • Do you have babel-cli installed? Try using babel@5 and/or do npm install -g babel-cli
    – user4695271
    Commented Dec 6, 2015 at 4:16
  • I initially did npm install -g babel-cli which installed v6. I couldn't even run the babel command with that. Then I did npm install -g babel@5, at that point I was able to run babel manually from my command line but I could not run my script from npm.
    – Ephapox
    Commented Dec 6, 2015 at 4:19
  • 1
    Try to install babel@5 also in your local project...
    – user4695271
    Commented Dec 6, 2015 at 4:35
  • That seemed to work... I'm curious though why didn't it work when I did a global install?
    – Ephapox
    Commented Dec 6, 2015 at 4:37
  • You need it globally for some other stuff, but lock it as a package in the project will trigger it correctly; the same happens for grunt-cli (usually)
    – user4695271
    Commented Dec 6, 2015 at 14:39

1 Answer 1

1

Install babel@5 globally (npm install babel@5 --global) as well as locally: npm install babel@5 --save-dev

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