简体   繁体   English

使用Angular CLI创建项目会出现错误

[英]Using Angular CLI to create a project gives errors

I am getting the following error when trying to use Angular CLI on Mac OS Sierra : 尝试在Mac OS Sierra上使用Angular CLI时出现以下错误:

$ ng new my-app Error: Path "/app/app.module.ts" does not exist. Path "/app/app.module.ts" does not exist.

I have tried the following approaches: 我尝试了以下方法:

Deleting NodeJS completely using the following commands: ( as stated on this stackoverflow post ) 使用以下命令完全删除NodeJS :( 如本stackoverflow文章所述

sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}

sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* /usr/local/lib/dtrace/node.d ~/.npm ~/.node-gyp

sudo rm -rf /opt/local/bin/node /opt/local/include/node /opt/local/lib/node_modules

Then re-install Angular CLI 然后重新安装Angular CLI

npm install -g @angular/cli

I have checked folder permissions and the information states that I have read/write access to the folder. 我已经检查了文件夹权限,并且该信息表明我具有对该文件夹的读/写访问权限。

What else could be the problem here? 还有什么可能是这里的问题?

I now have the following versions: 我现在有以下版本:

  • Angular CLI: 1.7.1 角CLI:1.7.1
  • Node: 8.9.4 节点:8.9.4
  • OS: darwin x64 操作系统:Darwin x64
  • NPM: v5.6.0 NPM:v5.6.0

Hope someone can help. 希望有人能帮忙。

Ok I have solved the problem. 好的,我已经解决了问题。

As well as doing all of the above. 以及执行以上所有操作。 I noticed that a folder... 我注意到一个文件夹...

/Users/my-user-name/node_modules

... still existed. ...仍然存在。 I did the following: 我做了以下事情:

  1. Repeated the "Uninstall NodeJS" steps as listed in my original post. 重复了我的原始帖子中列出的“卸载NodeJS”步骤。
  2. Deleted the node_modules folder found in /Users/my-user-name/node_modules 删除在/Users/my-user-name/node_modules找到的node_modules文件夹
  3. Re-installed Node via the download link on the NodeJS website 通过NodeJS网站上的下载链接重新安装Node
  4. Re-installed Angular CLI npm install -g @angular/cli 重新安装Angular CLI npm install -g @angular/cli
  5. Created a new project ng new my-app 创建了一个新项目ng new my-app
  6. Success! 成功!

Hopefully that helps anybody else who had similar issues. 希望对其他有类似问题的人有所帮助。

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

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