简体   繁体   English

使用 angular/cli 设置新项目时出错

[英]Error setting up new project with angular/cli

I am new to npm and Angular 2, I am trying to setup a new Angular 2 project using angular/cli.我是 npm 和 Angular 2 的新手,我正在尝试使用 angular/cli 设置一个新的 Angular 2 项目。

I am currently running:我目前正在运行:

Node v8.9.3 npm v5.6.0 Windows 10节点 v8.9.3 npm v5.6.0 Windows 10

First, I ran npm install -g @angular/cli which seemed to install just fine.首先,我运行npm install -g @angular/cli ,它似乎安装得很好。 Then I went to the folder where I wanted to start my project, ran ng new my-app but kept getting this error.然后我去了我想开始我的项目的文件夹,运行ng new my-app但一直收到这个错误。

npm WARN deprecated angular-cli@1.0.0-beta.22-1: angular-cli has been renamed to @angular/cli. npm WARN 已弃用 angular-cli@1.0.0-beta.22-1:angular-cli 已重命名为 @angular/cli。 Please update your dependencies.请更新您的依赖项。

npm WARN deprecated tough-cookie@2.2.2: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130 npm WARN 弃用了 strong-cookie@2.2.2:ReDoS 漏洞解析 Set-Cookie https://nodesecurity.io/advisories/130

npm WARN deprecated node-uuid@1.4.8: Use uuid module instead npm WARN 已弃用 node-uuid@1.4.8:改用 uuid 模块

npm WARN deprecated graceful-fs@3.0.11: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js npm WARN 已弃用 graceful-fs@3.0.11:请升级到 graceful-fs 4 以兼容当前和未来版本的 Node.js

npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue npm WARN 已弃用 minimatch@0.3.0:请更新到 minimatch 3.0.2 或更高版本以避免 RegExp DoS 问题

npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue npm WARN 已弃用 minimatch@2.0.10:请更新到 minimatch 3.0.2 或更高版本以避免 RegExp DoS 问题

npm WARN deprecated graceful-fs@1.2.3: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js npm WARN 已弃用 graceful-fs@1.2.3:请升级到 graceful-fs 4 以兼容当前和未来版本的 Node.js

npm WARN codelyzer@2.0.1 requires a peer of @angular/compiler@^2.3.1 || npm WARN codelyzer@2.0.1 需要@angular/compiler@^2.3.1 的对等体 || >=4.0.0-beta <5.0.0 but none is installed. >=4.0.0-beta <5.0.0 但没有安装。 You must install peer dependencies yourself.您必须自己安装对等依赖项。

npm WARN codelyzer@2.0.1 requires a peer of @angular/core@^2.3.1 || npm WARN codelyzer@2.0.1 需要@angular/core@^2.3.1 的对等体 ||

=4.0.0-beta <5.0.0 but none is installed. =4.0.0-beta <5.0.0 但没有安装。 You must install peer dependencies yourself.您必须自己安装对等依赖项。

npm WARN @ngtools/webpack@1.9.0 requires a peer of webpack@^2.2.0 || npm WARN @ngtools/webpack@1.9.0 需要 webpack@^2.2.0 的 peer || ^3.0.0 but none is installed. ^3.0.0 但没有安装。 You must install peer dependencies yourself.您必须自己安装对等依赖项。

npm WARN extract-text-webpack-plugin@2.1.2 requires a peer of webpack@^2.2.0 but none is installed. npm WARN extract-text-webpack-plugin@2.1.2 需要 webpack@^2.2.0 的同级,但没有安装。 You must install peer dependencies yourself.您必须自己安装对等依赖项。

npm WARN string-replace-loader@1.3.0 requires a peer of webpack@1 || npm WARN string-replace-loader@1.3.0 需要 webpack@1 的 peer || 2 || 2 || 3 but none is installed. 3 但没有安装。 You must install peer dependencies yourself.您必须自己安装对等依赖项。

npm WARN tslint-loader@2.1.5 requires a peer of tslint@^3.0.0 but none is installed. npm WARN tslint-loader@2.1.5 需要 tslint@^3.0.0 的同级,但没有安装。 You must install peer dependencies yourself.您必须自己安装对等依赖项。

npm WARN webpack-dev-middleware@1.12.2 requires a peer of webpack@^1.0.0 || npm WARN webpack-dev-middleware@1.12.2 需要 webpack@^1.0.0 的 peer || ^2.0.0 || ^2.0.0 || ^3.0.0 but none is installed. ^3.0.0 但没有安装。 You must install peer dependencies yourself.您必须自己安装对等依赖项。

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\\fsevents): npm WARN 可选跳过可选依赖:fsevents@1.1.3 (node_modules\\fsevents):

npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) npm WARN notsup 跳过可选依赖项:fsevents@1.1.3 不受支持的平台:想要 {"os":"darwin","arch":"any"}(当前:{"os":"win32","arch": "x64"})

npm ERR! npm 错误! path C:\\Web Development\\Projects\\angular 2 practice\\my-app\\node_modules\\@angular-cli\\ast-tools\\node_modules\\mkdirp\\bin\\cmd.js路径 C:\\Web Development\\Projects\\angular 2 practice\\my-app\\node_modules\\@angular-cli\\ast-tools\\node_modules\\mkdirp\\bin\\cmd.js

npm ERR! npm 错误! code ENOENT代码 ENOENT

npm ERR! npm 错误! errno -4058错误号 -4058

npm ERR! npm 错误! syscall chmod系统调用 chmod

npm ERR! npm 错误! enoent ENOENT: no such file or directory, chmod 'C:\\Web Development\\Projects\\angular 2 practice\\my-app\\node_modules\\@angular-cli\\ast-tools\\node_modules\\mkdirp\\bin\\cmd.js' enoent ENOENT:没有这样的文件或目录,chmod 'C:\\Web Development\\Projects\\angular 2 practice\\my-app\\node_modules\\@angular-cli\\ast-tools\\node_modules\\mkdirp\\bin\\cmd.js'

npm ERR! npm 错误! enoent This is related to npm not being able to find a file. enoent 这与 npm 无法找到文件有关。

npm ERR! npm 错误! enoent恩恩特

npm ERR! npm 错误! A complete log of this run can be found in:可以在以下位置找到此运行的完整日志:

npm ERR! npm 错误! C:\\Users\\Jason Kervin\\AppData\\Roaming\\npm-cache_logs\\2017-12-12T00_57_54_496Z-debug.log C:\\Users\\Jason Kervin\\AppData\\Roaming\\npm-cache_logs\\2017-12-12T00_57_54_496Z-debug.log

Package install failed, see above.软件包安装失败,请参见上文。

Try these steps:尝试以下步骤:

  1. npm cache clean --force npm 缓存清理 --force
  2. Open cmd and go to your current user cd C:\\Users{your user name here}打开 cmd 并转到您当前的用户 cd C:\\Users{your user name here}
  3. npm config set registry http://registry.npmjs.org/ npm 配置设置注册表http://registry.npmjs.org/
  4. npm install -g npm@latest npm install -g npm@latest
  5. npm install -g @angular/cli npm install -g @angular/cli

From the command line run从命令行运行

ng -v

This should output 1.6.0.这应该输出 1.6.0。 If it doesn't you have an older version of the CLI installed.如果没有,则您安装了旧版本的 CLI。

Run:跑:

npm cache --force clean

And then:进而:

npm install @angular/cli -g

If that doesnt work remove the folders in C:\\Users\\<username>\\AppData\\Roaming如果这不起作用,请删除C:\\Users\\<username>\\AppData\\Roaming中的文件夹

Use these lines:使用这些行:

npm cache clean --force

npm install -g @angular/cli@latest

After lots of research on this I came to a final solution, I tried lots of solutions but not worked for me.在对此进行了大量研究后,我得出了最终解决方案,我尝试了很多解决方案,但对我不起作用。 Try this it works for me, I'm using Ubuntu.试试这个它对我有用,我正在使用 Ubuntu。

Uninstall angular cli.卸载 angular cli。

Hit following command,点击以下命令,

sudo npm uninstall -g angular-cli

check version if version still present, check path检查版本 如果版本仍然存在,请检查路径

which ng

It will give following output它将给出以下输出

/usr/bin/ng

Now delete this by using现在使用删除它

sudo rm -rf /usr/bin/ng

then remove angular package然后删除角包

sudo rm -rf /usr/lib/node_modules/@angular

Now your angular cli is completely removed from your machine.现在您的 angular cli 已从您的机器中完全移除。

Now check angulars latest stable version and install it.现在检查 angulars 最新的稳定版本并安装它。

if problem is still present than uninstall node and delete global node_modules folder.如果问题仍然存在,则卸载节点并删除全局 node_modules 文件夹。

sudo apt-get purge nodejs

sudo apt-get autoremove

sudo rm -rf /usr/lib/node_modules

And install node and angular again.并再次安装节点和角度。

And try to create new project.并尝试创建新项目。 Hope it will work for you.希望它对你有用。 Thank You!谢谢你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM