本文介绍了generator-angular模块未创建新项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是yeoman工具的新手.我在Ubuntu 12中运行以下命令

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

我能够创建一个Web应用程序项目.之后,我尝试创建一个角度项目.首先,我运行命令

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.

当我运行命令

$ yo angular

我得到了错误:

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

输出为:

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

当我使用

$ npm install -g generator-backbone

它成功安装了软件包,并且当我在空文件夹中运行命令时

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

$ yo backbone

正在提供输出

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.

当我运行命令

$ npm config get prefix

它给了我输出

/home/ritesh/npm

也许我在这条路上犯了一些错误.谁能说出解决办法?

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

推荐答案

NODE_PATH可能配置不正确.在这种情况下,只需将NPM前缀添加到NODE_PATH.如果运行yo doctor,则输出可能为:

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

因此,要解决此问题,只需遵循医生的命令.如果您想更改.profile配置而不是bash的配置,只需执行以下命令即可:

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

这篇关于generator-angular模块未创建新项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 09:38
查看更多