【问题标题】:generator-angular module is not creating a new projectgenerator-angular 模块没有创建新项目
【发布时间】:2013-12-31 11:27:05
【问题描述】:

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

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

我能够创建一个网络应用项目。之后我尝试创建一个角度项目。首先我运行一个命令

$ npm install -g generator-angular

安装此生成器时没有显示错误。

当我运行命令时

$ 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.

如何解决这个问题?当我运行命令时

 $ 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

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

$ 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

也许我在这条路上犯了一些错误。谁能告诉我如何解决它?

【问题讨论】:

  • 如果你只运行yo会得到什么?
  • 在 Ubuntu 上 prefix 应该设置为 /usr。一定有为你设置不正确的地方。也许~/.npmrc 文件?
  • 感谢您的解决方案有效,我将前缀更改为 /usr,现在它的工作原理就像一个魅力。
  • 我看到的正是这个问题,但我的前缀是/usr/local/share/npm,看起来是正确的。
  • 我的系统是 usr/local/lib/npm

标签: yeoman yeoman-generator yeoman-generator-angular


【解决方案1】:

NODE_PATH 可能没有正确配置。在这种情况下,只需将 NPM 前缀添加到 NODE_PATH。如果你运行yo doctor,输出很可能是:

[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,只需执行以下命令:

echo "export NODE_PATH=$NODE_PATH:/home/eliranm/npm/lib/node_modules" >> ~/.profile && source ~/.profile

【讨论】:

  • 谢谢,帮我解决了这个问题。
【解决方案2】:

就我而言,

问题:“哟医生”在 Windows 10 上找不到任何错误。更新 yeoman 没有修复。 FIX:可能是权限问题。我以管理员身份打开命令提示符,运行 yo xxxx,它起作用了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-03
    • 2019-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-03
    • 2018-10-31
    • 2017-08-14
    相关资源
    最近更新 更多