I had installed babel-cli globally using npm. And I had a script.js file which contains the ES6 code. When I tried to compile that using $babel script.js -o out.js, it just copy all the contains of the script.js to out.js.
As far I concern, it should convert all the ES6 code to ES5.
Even if I run the script.js file without any content, it should show "use strict"; in my out.js. But it shows an empty file. Unable to figure out whats wrong?
Moreover I am unable to understand why "https://www.npmjs.com/package/babel-cli" says to install babel-cli globally where as "https://babeljs.io/docs/setup/#babel_cli" says to install that locally.
When I installed babel-cli locally and try to compile the script.js file it simply shows
'babel' is not recognized as an internal or external command,
operable program or batch file.
This should answer your question worked for me.
https://github.com/babel/babel/issues/4066
or install babel-cli globally and try it works then.
First Go to main directory or open new terminal
step 1: go to main directory
open terminal or (type cd so that you can directly switch in main directory)
step 2 : npm install -g babel-cli
now successfully install babel cli in your machine
npm install -g babel-cli
It works.
Related
I npm installed #vue/cli with npm install -g #vue/cli. but when I try the vue command I get -bash: vue: command not found. I added export PATH="/usr/local/Cellar/node/11.2.0/lib/node_modules/#vue/cli/bin:$PATH" to my bash profile and when I echo path in terminal I get
/usr/local/opt/openssl/bin:/usr/local/Cellar/node/11.2.0/lib/node_modules/#vue/cli/bin:/Users/jimmymona/.node/bin:/Applications/Postgres.app/Contents/Versions/latest/bin:/usr/local:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Postgres.app/Contents/Versions/latest/bin:/Applications/Postgres.app/Contents/Versions/latest/bin:/usr/local:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Which does have the path to the vue cli in it: /usr/local/Cellar/node/11.2.0/lib/node_modules/#vue/cli/bin
I also tried sudo installing it but that didn't work either
Anyone know what the issue is?
The path is wrong. The binary resides in /usr/local/Cellar/node/11.2.0/bin rather than .../lib/....
As you'll notice, the file in the latter directory is named as vue.js, not vue.
NPM creates a symlink without the .js extension to it in the bin directory, and that's the actual binary we typically refer to.
Typically we don't use the full path in .bashrc directly (in case the npm global path changes).
Rather, it's recommended to calculate it by combining the result of npm config get prefix and /bin, i.e.
export PATH="$PATH:$(npm config get prefix)/bin"
Node version : v8.11.4
npm version: 5.6.0
Commands fired
npm install -g vue-cli
npm install -g vue
vue install wepack test
Following error is thrown
'vue' is not recognized as an internal or external command,operable program or batch file.
When I type vue -v also, I am getting the above error
I also added to windows the path of Vue.js
I also noticed that vue.cmd is not coming the following directory
C:\Users\HP\AppData\Roaming\npm
Can anybody please help me to sort the problem
I solved my problem by not running my command terminal as an administrator. I opened my cmder terminal normally by double clicking and it worked.
I used command sudo npm install -g cordova to install cordova it shows result in terminal/Users/paramesh/.npm-packages/bin/cordova -> /Users/paramesh/.npm-packages/lib/node_modules/cordova/bin/cordova
+ cordova#8.0.0
updated 1 package in 47.732s
while creating project in cordova its bash: cordova not found
In my case, the path of npm was not set correctly. The package was installed on my local path even if I install it globally.
First, check npm path using npm root
If its not /usr/local/lib/node_modules then
set your path using npm config set prefix /usr/local
and again install you package npm install -g cordova
It's strange though that your system cannot find cordova after a global install with sudo. Have you tried reinstalling? If this doesn't help, try the following.
Restart the terminal and type this to check whether your system can find the cordova executable:
which cordova
If you get no output, it means your system cannot find the executable cordova binary. UNIX systems require executable binaries to be placed within the PATH environment variable. Try adding the following line in your ~/.bash_profile file:
$PATH=$PATH:/Users/paramesh/.npm-packages/lib/node_modules/cordova/bin/cordova
If you don't have a ~/.bash_profile, add it to the ~/.bashrc or ~/.profile file, whichever exists already. Then within the terminal you want to call cordova from, type:
source ~/.bash_profile
which cordova
This should give you the location of the cordova binary. Now you can use it.
I installed webpack and webpack-dev-server using NPM.
npm i webpack webpack-dev-server --save
I also did
npm link webpack webpack-dev-server
Now when I type webpack in the root of my project it says
'webpack' is not recognized as an internal or external command,
operable program or batch file.
I would hate it that everytime i install something I have to manually edit the path variable of my OS.
is there a better way of putting these utilities so that I can invoke them ... without editing my OS path variable?
is there a better way of putting these utilities so that I can invoke them ... without editing my OS path variable?
Yes, there is, npm i webpack -g
I ran sudo npm install -g generator-flask and it was saved. I was able to confirm by running npm list-g.
I then run yo flask. Thinking that this was going to work, I instead get an error message:
Error flask
You don't seem to have a generator with the name flask installed.
You can see available generators with npm search yeoman-generator and then install them with npm install [name].
To see the 22 registered generators run yo with the `--help` option.
I do as it tells me by running yo --help and discover that the flask generator is not there.
I try this with sudo npm install -g generator-angular-flask and the problem is recreated with Angular Flask. I'm assuming this is going to happen for all the generators which is why I've titled it as Yeoman not recognizing new npm installs.
Does anyone know why this has happened?
A workaround, but does solve the problem:
npm link generator-angular-flask
(as does just installing the module locally)
Usually it is a $NODE_PATH issue, but rather then guessing, run:
yo doctor
and follow the instructions!
Node path is the issue.
To setup path:
export NODE_PATH=$HOME/.node/lib/node_modules/
In my case node is in HOME directory.
I was having a similar issue. Basically Yeoman was showing No installed generators, even if I fired up yeoman and installed the generator again still no luck to run it.
I typed yo doctor and did the changes it recommends, but still no luck...
I then ran
export NODE_PATH=$HOME/.node/lib/node_modules/
Then I fired up Yeoman and still no luck.
I then decide run yo doctor again and voila! New errors. I then saw the final recommendation by the yo doctor so I decide to run it:
export NODE_PATH=$NODE_PATH:/Users/slickstyles/.npm-global/lib/node_modules
After I type yo and guess what I see? All my installed yeoman generators showing and working marvelously.
You can use:
yo doctor
and you will not something like:
npm root value is not in your NODE_PATH
[Info]
NODE_PATH = /home/action/.node/lib/node_modules/
npm root = /home/action/.parts/lib/node_modules
[Fix] Append the npm root value to your NODE_PATH variable
Add this line to your .bashrc
export NODE_PATH=$NODE_PATH:/home/action/.parts/lib/node_modules
Or run this command
echo "export NODE_PATH=$NODE_PATH:/home/action/.parts/lib/node_modules" >> ~/.bashrc && source ~/.bashrc
and try again:
npm install -g generator-webapp
Check if you have NODE_PATH set. To set it open a terminal and type (assuming you have node under /opt/node/ and use bash shell)
echo "export NODE_PATH=/opt/node:/opt/node/lib/node_modules" >> ~/.bashrc && . ~/.bashrc
Once done, run yo doctor. If all is ok, run yo to see your installed generators.