Yeoman can't recognize a generator that was in

2019-04-19 00:14发布

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?

标签: npm yeoman
6条回答
beautiful°
2楼-- · 2019-04-19 00:34

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.

查看更多
Root(大扎)
3楼-- · 2019-04-19 00:38

Usually it is a $NODE_PATH issue, but rather then guessing, run:

yo doctor

and follow the instructions!

查看更多
爷的心禁止访问
4楼-- · 2019-04-19 00:42

Node path is the issue. To setup path:

export NODE_PATH=$HOME/.node/lib/node_modules/

In my case node is in HOME directory.

查看更多
聊天终结者
5楼-- · 2019-04-19 00:44

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  
查看更多
成全新的幸福
6楼-- · 2019-04-19 00:48

A workaround, but does solve the problem:

npm link generator-angular-flask

(as does just installing the module locally)

查看更多
看我几分像从前
7楼-- · 2019-04-19 00:49

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.

查看更多
登录 后发表回答