» npm install @babel/cli
Factsheet
There are two problems here. First, you need a package.json file. Telling npm to install without one will throw the npm WARN enoent ENOENT: no such file or directory error. In your project directory, run npm init to generate a package.json file for the project.
Second, local binaries probably aren't found because the local ./node_modules/.bin is not in $PATH. There are some solutions in How to use package installed locally in node_modules?, but it might be easier to just wrap your babel-cli commands in npm scripts. This works because npm run adds the output of npm bin (node_modules/.bin) to the PATH provided to scripts.
Here's a stripped-down example package.json which returns the locally installed babel-cli version:
{
"scripts": {
"babel-version": "babel --version"
},
"devDependencies": {
"babel-cli": "^6.6.5"
}
}
Call the script with this command: npm run babel-version.
Putting scripts in package.json is quite useful but often overlooked. Much more in the docs: How npm handles the "scripts" field
When I found this question, I was looking for
$ npm install -g babel-cli
The @ signifies the usage of an "npm scope":
https://docs.npmjs.com/about-scopes
It's basically a way to avoid name clashing, so we could both own modules @cdbrouk/foo and @jedrichards/foo. Babel moved to using the @babel scope a while ago, so the @babel/... modules are the correct ones to use.
if you want that your system recongnize the command babel-node you should install the dependency @babel/cli with the global scope:
npm install -g @babel/cli
Otherwise, you should invoque babel-node via npx: npx babel-node...
» npm install babel-cli