-bash: yo: command not found - npm

Like a lot of people I am also having issues with Yeoman.
Error -bash: yo: command not found in OSx.
I tried adding export PATH=/usr/local/share/npm/bin:$PATH on my .bash_profile as suggested by some folks and still same error.
I've lost 2 hours of my productivity trying to fix Yeoman bugs and still nothing.
Does anyone know any good solution that fixes the -bash: yo: command not found ?

I found that for recent versions of npm, all node packages are installed in the ~/npm/bin/ directory.
So add those lines to your $PATH in the .profile file :
export PATH=$PATH:~/npm/bin
Then do :
source ~/.profile
yo -v

Finally found a solution for this.
First I had to uninstall and install yo again:
npm remove -g yo
npm install -g yo
I also added a symlink to the bash_profile to make yo work. The following line: PATH=${PATH}:~/.node/bin After that restart the prompt for the change to take action.
Please check this for more references: Why are my Yeoman generators installing in the wrong place?

try to add an symbolic-link (ln -s) into the /sbin -directory.
like:
ln -s /sbin/ /usr/local/share/npm/bin/yo

This also seems to work :)
sudo `yo angular2-ts [appname]`
where [appname] is the name of your app (without the []) :)

just give access for the user to read write execute in the folder webapp
sudo chmod 777 webapp
cd webapp
yo angular [appname]

Related

Remove "npm update check failed" message at log on

I did a bunch of commands weeks ago that caused the following message to appear every time I access iTerm:
npm update check failed
Try running with sudo or get access
to the local update config store via
sudo chown -R $USER:$(id -gn $USER) /folder/folder/.config
How do I remove this message? And anything else it could have dumped in my computer?
It's a persistent message at log on. Unfortunately, I do not know what commands triggered this. And .bash_history file didn't help me find which command caused this.
I had a similar issue. I solved it by running the following command in the iterm2 application.
sudo chown -R $USER:$(id -gn $USER) /folder/folder/.config
and restarted the iterm2 application.
Just delete the configstore folder under the corresponding folder. And running the project again will regenerate the folder without reporting an error.
Run the command as superuser by starting the command with "sudo"
If you like to update your packages listed in your local package.json npm auto update package.
Try this one:
npm install asdf

Truffle command not found after installation

I installed truffle through npm with the following:
sudo npm install -g truffle
but when I run truffle list on the console it just gives me
bash: truffle: command not found
I had a similar problem. I ran npm i -g truffle and then when I tried to run truffle init I got an error: zsh: command not found: truffle. What solved it for me is to create a local node_modules with truffle installed in it, and then run that copy.
run npm init and make a new npm project
run npm i truffle
run ./node_modules/.bin/truffle init and it should work!
Please make sure you have the latest version of npm and node installed. I had the same issue, I updated npm and node to latest version and it worked.
npm install -g truffle works.
After installing truffle:
npm install -g truffle
Run on your project folder:
npx truffle init
I did it on a Virtual box and had the same issue, but it worked after I restarted the computer. Hopefully that works for you too
You should add the following to your path system variable.
C:\Users\UserName\AppData\Roaming\npm
(This folder contains the truffle.cmd file)
I have tried and it works.
I tried everything. Followed the instruction on official truffle website and above answers.
Still it didn't seem to worked.
Finally, this worked for me.
Go to C:\Users\Username\AppData\Roaming\npm
There you will find truffle.cmd Double click on it and your done.
npm i truffle does the exact same thing as npm install -g truffle except that installs it globally, and without -g it will be installed on the local folder. Try to update the npm, node, and probably you have a broken node installation from previous versions.
Using npm install -g truffle worked for me instead of npm i truffle
Nothing above worked for me, but I did:
nix truffle unbox react
truffle develop
atom . //opens up the react file project in the atom platform
Try to start with your command like
npx truffle <your command>
You should add C:\Users\UserName\AppData\Roaming\npm (it contains truffle.cmd file) to the path user variables. I have tried and it works
If you have a custom path for your packages, then make sure that you are exporting it when the terminal loads.
For bash:
nano ~/.profile
For zsh:
nano ~./zshrc
And add your custom path, most of the time this will be "npm-global".
export PATH=~/.npm-global/bin:$PATH
These are two simple steps the properly solve this problem for Linux Users:
1- Configure npm to install software globally in your home directory as follows :
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
2- If you are using bash, then execute the following:
echo -n "export PATH=~/.npm-global/bin:$PATH" >> ~/.profile
However, if you are using zsh instead, then execute the following command:
echo -n "export PATH=~/.npm-global/bin:$PATH" >> ~/.zshrc
Note that, if you are using both bash and zsh, it is better to execute the two commands above.

apidocjs not returning anything in response

I have installed 'apidoc' after installing 'npm' and 'node' for my API documentation by the help of following command:
npm install apidoc -g
After installing apidoc globally, I simply ran below command on my project directory (assuming apidoc will consider its default template file):
apidoc
In result no errors and no documentation generated.
Similarly, I have tried:
apidoc -i ~/PROJECTS/jruby/project/webservice/ -o ~/PROJECTS/apidocs/apidoc/ -t ~/PROJECTS/apidocs/mytemplate/
But nothing happens, in that case I had nothing on 'mytemplate' directory.
Can you guys please tell me what I've missed to install/consider? and why nothing is appearing on command execution?
Note: I'm using this for my ruby application, but unable to install its gem as we're running our application on ruby 1.9 and it requires ruby 2.0. I need an independent solution that should works for other projects as well.
Thank you.
I got the solution; copied 'package.json' file from https://github.com/apidoc/apidoc and ran below command for npm
npm install
after getting success install nodejs properly by following steps:
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install nodejs
then went to the project directory and ran the following command:
apidoc
after success of above command got html document in doc/ directory inside project. Cheers !

Yeoman can't recognize a generator that was installed globally

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.

Urturn API ur: command not found

I am trying to install urturn api and write my own expression for urturn.com
following http://webdoc.github.com/urturn-expression-api/#!guides/start
After:
npm install urturn-toolbelt -g
I am trying to run sandbox with:
ur sandbox
and got error:
-bash: ur: command not found
Please help
P.S. I am on Mac Os
thanks
It is likely your nodeJS npm/bin folder that is not included in your PATH.
Can you check your PATH variable?
Node NPM package bin files are all symlinked in the same ./bin folder. If you installed NodeJS using Homebrew (brew install node), it should be /usr/local/share/npm/bin.
You can echo your current path using:
echo $PATH
If the folder above does not appear in the list, check your .bashrc or .bash_profile files and fix any problem.
A fix that is likely to work is to add the following line in ~/.bash_profile
PATH=$PATH:/usr/local/share/npm/bin