问题
I am new to npm and Angular 2, I am trying to setup a new Angular 2 project using angular/cli.
I am currently running:
Node v8.9.3 npm v5.6.0 Windows 10
First, I ran npm install -g @angular/cli
which seemed to install just fine. Then I went to the folder where I wanted to start my project, ran ng new my-app
but kept getting this error.
npm WARN deprecated angular-cli@1.0.0-beta.22-1: angular-cli has been renamed to @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 deprecated node-uuid@1.4.8: Use uuid module instead
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 deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
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 codelyzer@2.0.1 requires a peer of @angular/compiler@^2.3.1 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer@2.0.1 requires a peer of @angular/core@^2.3.1 ||
=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ngtools/webpack@1.9.0 requires a peer of webpack@^2.2.0 || ^3.0.0 but none is installed. 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. You must install peer dependencies yourself.
npm WARN string-replace-loader@1.3.0 requires a peer of webpack@1 || 2 || 3 but none is installed. 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. You must install peer dependencies yourself.
npm WARN webpack-dev-middleware@1.12.2 requires a peer of webpack@^1.0.0 || ^2.0.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: 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 ERR! path C:\Web Development\Projects\angular 2 practice\my-app\node_modules\@angular-cli\ast-tools\node_modules\mkdirp\bin\cmd.js
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall chmod
npm ERR! 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'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Jason Kervin\AppData\Roaming\npm-cache_logs\2017-12-12T00_57_54_496Z-debug.log
Package install failed, see above.
回答1:
From the command line run
ng -v
This should output 1.6.0. If it doesn't you have an older version of the CLI installed.
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
回答2:
Use these lines:
npm cache clean --force
npm install -g @angular/cli@latest
回答3:
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.
Uninstall 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.
Now check angulars latest stable version and install it.
if problem is still present than uninstall node and delete global node_modules folder.
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!
回答4:
Try these steps:
- npm cache clean --force
- Open cmd and go to your current user cd C:\Users{your user name here}
- npm config set registry http://registry.npmjs.org/
- npm install -g npm@latest
- npm install -g @angular/cli
来源:https://stackoverflow.com/questions/47763992/error-setting-up-new-project-with-angular-cli