generator-angular模块不会创建新项目

 jianji 发布于 2023-02-07 12:57

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

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

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

$ 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

也许我在这条路上犯了一些错误.任何人都可以告诉你如何解决它?

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
    

    2023-02-07 13:00 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有