Closed le0zh0u closed 8 years ago
Hello @le0zh0u, could you run the following three commands and post their output? The comments show an example of what they output on my system. The paths may be completely different, but it is interesting if npm
is looking in the correct directory for globally installed modules.
which yo
# /Users/sthzg/.nvm/versions/node/v6.2.2/bin/yo
which node
# /Users/sthzg/.nvm/versions/node/v6.2.2/bin/node
npm -g root
# /Users/sthzg/.nvm/versions/node/v6.2.2/lib/node_modules
which yo
-> /usr/local/bin/yo
which node
-> /usr/local/bin/node
npm -g root
-> /usr/local/lib/node_modules
I think the paths are similar with yours. Should I config some file to make npm
or yo
know where is the correct directory for globally installed modules.
Thanks.
That's looking good. Does yo doctor
output any problems?
yo doctor
# Running sanity checks on your system
#
# ✔ Global configuration file is valid
# ✔ NODE_PATH matches the npm root
# ✔ Node.js version
# ✔ No .bowerrc file in home directory
# ✔ No .yo-rc.json file in home directory
# ✔ npm version
#
# Everything looks all right!
doctor outputs everything is ok...
Yeoman Doctor
Running sanity checks on your system
✔ Global configuration file is valid
✔ NODE_PATH matches the npm root
✔ Node.js version
✔ No .bowerrc file in home directory
✔ No .yo-rc.json file in home directory
✔ npm version
Everything looks all right!
How can I let yo
know where is the correct directory for globally installed modules?
I think maybe yo
is looking in a wrong directory, so that it can't find any generator. Because I can run yo react-wepack
under the generator-react-webpack
directory.
Thanks.
Likely, yes, but that is what yo doctor
should have checked 💭 . When you run the following, does it find generator-react-webpack
installed in /usr/local/lib/node_modules
?
npm -s ls -g --depth=0 |grep 'generator-'
# ├── generator-react-webpack -> /usr/local/lib/node_modules/generator-react-webpack
npm -s ls -g --depth=0 |grep 'generator-'
├── generator-react-webpack@3.3.4
That outputs its name. And I do cd /usr/local/lib/node_modules
, I find generator-react-webpack
:
cd /usr/local/lib/node_modules
-> /usr/local/lib/node_modules
ls
->
bower generator-react-webpack supervisor
cnpm gulp webpack
express-generator npm yo
@le0zh0u I might be tired and blind, but all paths seem to match so far. One more set of sanity checks:
If you run ls -l /usr/local/bin/yo
, does this correctly link to /usr/local/lib/node_modules/yo/lib/cli.js
? (also for completeness, could you paste your versions of yo, node and npm)?
ls -lha /Users/sthzg/.nvm/versions/node/v6.2.2/bin/yo
# ... /Users/sthzg/.nvm/versions/node/v6.2.2/bin/yo -> ../lib/node_modules/yo/lib/cli.js
@le0zh0u,
we had this problems once before. In the last case, it was a direct install that needed all global modules to be installed as root. The rights for the generator where then not picked up by "yo" correctly. Could you try installing nvm (https://github.com/creationix/nvm) and test with this? It will install node locally, which means you wont need admin rights to install globally.
@weblogixx ,
It works. I uninstall node on my laptop, and install nvm and node by your way. In the project directory, the command runs successfully. I don't know why. May it is a little bug.:)
Well, yesternight, I grant node_module
folder to current user. And I don't need admin rights to install globally. But it didn't work.
I use the command
npm install -g generator-react-webpack
to install react-webpack generator to yo. It works. After that, I runyo react-webpack
, but it failed. And it shows:Error react-webpack You don't seem to have a generator with the name react-webpack installed. You can see available generators with npm search yeoman-generator and then install them with npm install [name]. To see the 0 registered generators run yo with the '--help' option.
That means I didn't install any generator. But in root of npm's installation directory, I find 'generator-react-webpack' folder, and in that folder the command of
yo react-webpack
can work.I use iterm and zsh in MacOS. And I try
yo completion
, it shows some options, I choose 'Zsh config file', but it shows even I usesudo
:oh oh Error: EACCES: permission denied, open '/usr/local/lib/node_modules/.yo_npminstall/tabtab/1.3.2/tabtab/.completions/yo.zsh' at Error (native)
What should I do to fix it and use generator?