升级Angular CLI至6.0.0后无法创建Angular 6新项目
ng new Errors Hey there, let's work through the issues you're hitting after upgrading to Angular CLI 6.0.0! These kinds of glitches are pretty common with major CLI version jumps, so here are practical steps to resolve them:
Step 1: Clean Up Old CLI Installs & Cache
First, let's wipe out any leftover global CLI files and clear npm's cache to eliminate corrupted data:
npm uninstall -g @angular/cli npm cache clean --force
(Note: For npm 5+, you can also use npm cache verify, but clean --force is more thorough for troubleshooting.)
Step 2: Verify Node.js Compatibility
Angular CLI 6.0.0 requires Node.js 8.x or higher. Check your current version with:
node -v
If your Node version is below 8.x, upgrade to a compatible LTS release—this is a frequent culprit for post-upgrade errors.
Step 3: Reinstall the Exact CLI Version
Now install the 6.0.0 version globally:
npm install -g @angular/cli@6.0.0
Step 4: Confirm the CLI Version
Run this command to make sure the version is showing correctly:
ng --version
You should see @angular/cli: 6.0.0 listed here.
Step 5: Troubleshoot ng new Errors
If creating a new project still fails:
- Make sure you're in an empty directory (no existing
node_modulesorpackage-lock.jsonfiles that might conflict). - Try using
npxto run the CLI directly, bypassing any global install quirks:npx @angular/cli@6.0.0 new my-app - On Linux/macOS, ensure you have proper permissions (run the command with
sudoif needed); on Windows, open your command prompt as an administrator.
Why This Happens
Most often, these issues stem from:
- Residual cache files from previous CLI versions
- Mismatched global/local CLI versions
- Incompatible Node.js versions that don't support CLI 6.0.0
内容的提问来源于stack exchange,提问作者Ran Lorch

