generator-angular2 icon indicating copy to clipboard operation
generator-angular2 copied to clipboard

Error when running the command yo angular2

Open ghost opened this issue 8 years ago • 11 comments

I've followed as per your tutorials and find the following error when running yo angular2.

Error angular2 

You don't seem to have a generator with the name angular2 installed.
You can see available generators with npm search yeoman-generator 
and then install them with npm install [name].

The yo and angular-generator has been installed using the following command: npm install -g yo generator-angular2

ghost avatar Mar 21 '16 15:03 ghost

what happens when you simply type yo in the console? Is it in the available list?

Ariestattoo avatar Mar 22 '16 00:03 Ariestattoo

Yeah it sounds like the installation may have failed, try re-running npm install -g yo generator-angular2 and see if there are any errors reported.

chrisdwheatley avatar Mar 22 '16 09:03 chrisdwheatley

@Ariestattoo when typed yo the following menu comes up:

? 'Allo Anoop! What would you like to do? (Use arrow keys)
  Run a generator
❯ Angular 
  Express Angular 
  Ionic 
  Mobileangularui 
  Webapp 
  Karma 
(Move up and down to reveal more choices)

@swirlycheetah I've run the command sudo npm install -g yo generator-angular2 many times, before posting this bug and even as I'm typing :(

ghost avatar Mar 23 '16 15:03 ghost

In general it would be preferable not to run the install as a superuser. What output are you receiving when running the install as swirlycheetah recommended?

Ariestattoo avatar Mar 23 '16 20:03 Ariestattoo

When running without sudo:

npm WARN deprecated [email protected]: this package has been reintegrated into npm and is now out of date with respect to npm
npm WARN deprecated [email protected]: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible.
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/generator-angular2
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/yo
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
/usr/local/lib
+-- [email protected] 
`-- [email protected] 

npm ERR! Linux 3.16.0-67-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "yo" "generator-angular2"
npm ERR! node v5.9.0
npm ERR! npm  v3.7.3
npm ERR! path /usr/local/lib/node_modules/generator-angular2
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access

npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/generator-angular2'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules/generator-angular2']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules/generator-angular2' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/anoop/npm-debug.log

ghost avatar Mar 24 '16 16:03 ghost

Running yo

? 'Allo Anoop! What would you like to do? (Use arrow keys)
  Run a generator
❯ Angular 
  Express Angular 
  Ionic 
  Mobileangularui 
  Webapp 
  Karma 

ghost avatar Mar 24 '16 16:03 ghost

It looks like without sudo the install is failing due to permission issues. When you run sudo npm install -g generator-angular2 what is the output in the console?

chrisdwheatley avatar Mar 28 '16 12:03 chrisdwheatley

If you are trying to install with "-g" flag that means it will be installed globally on your system and that's why you need to run this command with "sudo".

vuxor avatar Mar 28 '16 20:03 vuxor

@swirlycheetah when using sudo npm install -g generator-angular I get the following:

 [email protected] postinstall /usr/local/lib/node_modules/yo
> yodoctor


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!
- [email protected] node_modules/generator-angular2/node_modules/color-convert
- [email protected] node_modules/yo/node_modules/color-convert
/usr/local/lib
+-- [email protected] 
| +-- [email protected]
| | `-- [email protected] 
| +-- [email protected]
| | `-- [email protected]
| |   `-- [email protected]
| |     +-- [email protected]
| |     | `-- [email protected] 
| |     `-- [email protected]
| |       `-- [email protected]
| |         `-- [email protected] 
| `-- [email protected]
|   +-- [email protected]
|   | +-- [email protected]
|   | | `-- [email protected]
|   | |   `-- [email protected]
|   | |     `-- [email protected] 
|   | `-- [email protected]
|   |   +-- [email protected]
|   |   | `-- [email protected]
|   |   |   `-- [email protected]
|   |   |     `-- [email protected] 
|   |   |       `-- [email protected] 
|   |   `-- [email protected] 
|   `-- [email protected] 
|     +-- [email protected]
|     | `-- [email protected] 
|     `-- [email protected] 
`-- [email protected] 
  +-- [email protected] 
  | `-- [email protected] 
  `-- [email protected]
    `-- [email protected]
      `-- [email protected]
        `-- [email protected]
          `-- [email protected] 

Running yo

anoop@anoop-vostro-3550:~/nodejs/workshop/fsbs$ yo
? 'Allo Anoop! What would you like to do? (Use arrow keys)
  Run a generator
❯ Angular 
  Express Angular 
  Ionic 
  Mobileangularui 
  Webapp 
  Karma 

ghost avatar Mar 31 '16 14:03 ghost

I'm not entirely sure but it looks like if you've installed the generator with sudo and the try running yo command without it then you don't have permission to use the generator. You don't need sudo to install modules globally. Some resources which may help you out:

  • http://www.johnpapa.net/how-to-use-npm-global-without-sudo-on-osx/
  • https://docs.npmjs.com/getting-started/fixing-npm-permissions
  • https://stackoverflow.com/questions/19352976/npm-modules-wont-install-globally-without-sudo
  • https://github.com/creationix/nvm

chrisdwheatley avatar Apr 15 '16 20:04 chrisdwheatley

Sorry with delayed post, my modem was under repair :)

These are some warnings that are displayed when installing:

npm WARN deprecated [email protected]: this package has been reintegrated into npm and is now out of date with respect to npm
npm WARN deprecated [email protected]: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible.

ghost avatar Apr 22 '16 13:04 ghost