angular - 找不到 API 编译器 cli、函数 VERSION 错误:找不到 API 编译器 cli、函数 VERSION
问题描述
我创建了一个新的 Angular 6 应用程序,当我尝试使用 ng serve --open 运行该应用程序时,它会出现此错误。什么可能导致错误,我应该怎么做才能解决这个问题?
Could not find API compiler-cli, function VERSION Error: Could not find API compiler-cli, function VERSION
at _error (/home/linux/Documents/angu/my-app/node_modules/@ngtools/webpack/src/ngtools_api.js:8:11)
at getApiMember (/home/linux/Documents/angu/my-app/node_modules/@ngtools/webpack/src/ngtools_api.js:11:32)
at Object.<anonymous> (/home/linux/Documents/angu/my-app/node_modules/@ngtools/webpack/src/ngtools_api.js:50:19)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/home/linux/Documents/angu/my-app/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:28:23)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
解决方案
尝试这个
Step 1: npm install -g @angular/cli@latest
Step 2: ng new name-of-project (ignore if project already created)
Step 3: cd name-of-project (ignore if project already created)
Step 4: npm install @angular/cli --save-dev
Step 5: npm install @angular/compiler-cli --save-dev
Step 6: ng serve