2

I can't run babel-cli from my local node modules folder.

I installed babel-cli in my local node modules folder using:

npm install babel-cli --save-dev

So that I do not have to install babel globally. I can see it installed in node_modules and is added to the package.json file.

  "devDependencies": {
"babel-cli": "^6.18.0"
}

When I build using the command

babel app.js -o build/app.js

I get a message saying babel

The program 'babel' can be found in the following packages:
* babel-1.4.0
* openbabel
Try: sudo apt-get install <selected package>

I am using Ubuntu 14.4

I tried to access the babel through the script by adding

 "scripts": {
"babelversion": "babel --version",
 }

when I run the command 'npm run babelversion' I get the same error

sh: 1: babel: Permission denied

and and NPM error with exit status 126

How do I get a local babel (without installing it globally) to work?

Bee
  • 21
  • 1
  • 3

4 Answers4

6

I had this issue and clearing then reinstalling everything worked:

  >> npm cache clean --force
  >> rm -rf node_modules
  >> npm install

Note: it requires two force commands, so make sure you only try this in a repo wherein which you're willing to reinstall everything.

Jared Wilber
  • 6,038
  • 1
  • 32
  • 35
1

I had the same problem, found the solution by calling the program locally, like this:

./node_modules/babel-cli/bin/babel.js app.js -o build/app.js
Cristóvão Trevisan
  • 1,775
  • 17
  • 18
0

If you're on Linux give the Owner group execution permission. I checked on my laptop and the permissions were as such: 644 (i.e. Read-Write for Owner, Read for Group, Read for Other). So I did: chmod 744 babel.

https://unix.stackexchange.com/questions/109485/why-is-permission-denied-for-npm-start-using-node-dev

https://en.wikipedia.org/wiki/Chmod

http://ss64.com/bash/chmod.html

Using sudo won't make a difference.

Community
  • 1
  • 1
James Yen
  • 241
  • 1
  • 2
  • 7
0

Just to help someone, the error might be an incompatible format of the drive. I changed from my pendrive to the /Documents inside the hdd and all the "permission denied" errors are gone.

See this post: "Permission Denied" in Node on Linux, when running start-script /w local nodemon/mocha/babel-node

PauloBorba
  • 156
  • 3
  • 5