angular-cliでCannot find module '@angular-devkit/core'エラーが出た件
環境:windows
angular/angular-cli: CLI tool for Angular
ng new PROJECT-NAME
cd PROJECT-NAME
ng serve
エラーが出ました
C:\Temp\PROJECT-NAME>ng serve
module.js:472
throw err;
^
Error: Cannot find module '@angular-devkit/core'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Temp\PROJECT-NAME\node_modules\@angular-devkit\schematics\src\tree\virtual.js:10:16)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
C:\Temp\PROJECT-NAME>ng --version
module.js:472
throw err;
^
以下ページに同様のIssuが立っていました。
npm update -g @angular/cli
その中で解決策が以下のように提言されていました。
- npm update -g @angular/cli
- editing my package.json changing the line
"@angular/cli": "1.6.0",
to
"@angular/cli": "^1.6.0", - npm update
did the trick.
という事で、"^1.6.0"に変更したら動きました。
提言者が「did the trick.」と言ってたようにトリックですね。
C:\Temp\PROJECT-NAME>ng --version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 1.6.8
Node: 7.2.1
OS: win32 x64
Angular: 5.2.4
... animations, common, compiler, compiler-cli, core, forms
以下略