-->

Yeoman angular generator install runs but generato

2019-03-15 01:16发布

问题:

I've tried to install the yeoman angular generator with the following:

npm install -g generator-angular

It all looks like it's installed properly...

...
npm http GET https://registry.npmjs.org/string_decoder
npm http 304 https://registry.npmjs.org/string_decoder
npm http GET https://registry.npmjs.org/event-emitter
npm http GET https://registry.npmjs.org/next-tick
npm http 304 https://registry.npmjs.org/event-emitter
npm http 304 https://registry.npmjs.org/next-tick
generator-angular@0.7.1 /Users/rich/.node/lib/node_modules/generator-angular
├── chalk@0.3.0 (has-color@0.1.4, ansi-styles@0.2.0)
├── wiredep@0.4.2 (chalk@0.1.1, lodash@1.3.1)
└── yeoman-generator@0.13.4 (dargs@0.1.0, diff@1.0.8, debug@0.7.4, rimraf@2.2.6, chalk@0.2.1, text-table@0.1.1, mime@1.2.11, async@0.2.10, mkdirp@0.3.5, isbinaryfile@0.1.9, shelljs@0.1.4, underscore.string@2.3.3, glob@3.2.9, iconv-lite@0.2.11, tar@0.1.19, findup-sync@0.1.3, lodash@1.3.1, request@2.25.0, cheerio@0.12.4, inquirer@0.3.5)

Full log here: https://dl.dropboxusercontent.com/s/hs5dgy1i6f90vu4/angular-generator-log.txt

But every time I do: yo angular I get: You don't seem to have a generator with the name angular installed.

yo doctor says everything is ok and I have angular installed globally with npm.

yo --help shows:

Please choose a generator below.


Mocha
  mocha:app

Webapp
  webapp:app

I'm a bit baffled as there aren't any errors with installation...?

回答1:

Strangely enough I fixed this very same problem by replacing

npm install -g generator-angular

with

npm install -G generator-angular

Note the capital G in the second command



回答2:

I used this

npm remove -g yo generator-* yeoman-generator 
npm install -g yo generator-angular

and now everything works very well



回答3:

I've seen this problem a bunch of times, there are some problems because of node path. What you can do to fix this is very simple. You just need to tell node what is going to be the folder for global packages and this folder needs to have the same permissions as the user.

return the node path

npm config get prefix

create a node folder that you can destroy whenever you want

mkdir -p ~/.node

tell node to use this folder

npm config set prefix ~/.node

then try again npm install -g yo