简体   繁体   中英

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 :

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

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

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
  • Node: 8.9.4
  • OS: darwin x64
  • 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.
  2. Deleted the node_modules folder found in /Users/my-user-name/node_modules
  3. Re-installed Node via the download link on the NodeJS website
  4. Re-installed Angular CLI npm install -g @angular/cli
  5. Created a new project ng new my-app
  6. Success!

Hopefully that helps anybody else who had similar issues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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