Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

generator-angular module is not creating a new project

I am new to yeoman set of tools. I run following commands in Ubuntu 12

$ npm install -g yo
$ npm install -g generator-webapp
$ yo webapp           

I am able to create a web app project. After that I tried to create an angular project. First I run a command

$ npm install -g generator-angular

And no error is displayed with installation of this generator.

When I run the command

$ yo angular 

I get the error:

Error angular
You don't seem to have a generator with the name angular installed.
You can see available generators with npm search yeoman-generator and then install them with npm install [name].
To see the 2 registered generators run yo with the `--help` option.

How to resolve this? When I run the command

 $ ls $(npm config get prefix)/lib/node_modules

output is:

bower  generator-angular  generator-karma  generator-mocha  generator-webapp  grunt-cli  yo

The same problem occurred when I use to install generator-backbone using

$ npm install -g generator-backbone

It installs the package successfully and when I run the command in an empty folder

$ yo backbone 

It's giving the output

Error backbone 

You don't seem to have a generator with the name backbone installed.
You can see available generators with npm search yeoman-generator and then install them with npm install [name].
To see the 2 registered generators run yo with the `--help` option.

When I run the command

$ npm config get prefix

It's giving me the output

/home/ritesh/npm

Perhaps I am doing some mistake in this path. Can any one tell how to resolve it?

like image 344
Ritesh Mehandiratta Avatar asked Dec 31 '13 11:12

Ritesh Mehandiratta


People also ask

Where can I run Ng generate component?

From a terminal window, navigate to the directory containing your application. Run the ng generate component <component-name> command, where <component-name> is the name of your new component.

What is the command to generate a new module in angular 7?

Getting Started With Angular 7 Once you have the angular cli installed, use the ng cli command to create a new Angular project.


1 Answers

NODE_PATH is probably not configured properly. In which case, just add the NPM prefix to the NODE_PATH. If you run yo doctor, the output is likely to be:

[Yeoman Doctor] Uh oh, I found potential errors on your machine
---------------

[Error] NPM root value is not in your NODE_PATH
  [info]
    NODE_PATH = /usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
    NPM root  = /home/eliranm/npm/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/eliranm/npm/lib/node_modules
    Or run this command
      echo "export NODE_PATH=$NODE_PATH:/home/eliranm/npm/lib/node_modules" >> ~/.bashrc && source ~/.bashrc

So, in order to solve this, just follow the doctor's orders. If you prefer to change the .profile configuration rather the bash's, just execute this:

echo "export NODE_PATH=$NODE_PATH:/home/eliranm/npm/lib/node_modules" >> ~/.profile && source ~/.profile
like image 129
Eliran Malka Avatar answered Jan 18 '23 11:01

Eliran Malka