javascript - 使用 webpack 构建 Angular 6 应用程序时出错
问题描述
我正在尝试使用 webpack 构建 angular 6 应用程序。
得到错误为
./src/main.ts 中的错误模块构建失败(来自 ./node_modules/@ngtools/webpack/src/index.js):错误:找不到模块'@angular/compiler-cli/ngcc'
包.json
{
"name": "cloud-complince",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "webpack",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^6.1.10",
"@angular/common": "^6.1.10",
"@angular/compiler": "^6.1.10",
"@angular/core": "^6.1.10",
"@angular/forms": "^6.1.10",
"@angular/http": "^6.1.10",
"@angular/platform-browser": "^6.1.10",
"@angular/platform-browser-dynamic": "^6.1.10",
"@angular/router": "^6.1.10",
"chart.js": "^2.8.0",
"chartjs-plugin-datalabels": "^0.4.0",
"classlist.js": "^1.1.20150312",
"core-js": "^2.6.9",
"ngx-cookie": "^3.0.1",
"rxjs": "~6.2.0",
"rxjs-compat": "^6.5.2",
"web-animations-js": "^2.3.2",
"zone.js": "^0.8.29"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.8.9",
"@angular/cli": "^6.2.7",
"@angular/compiler-cli": "^6.1.0",
"@angular/language-service": "^6.1.10",
"@ngtools/webpack": "^8.1.1",
"@types/jasmine": "^2.8.16",
"@types/jasminewd2": "^2.0.6",
"@types/node": "~8.9.4",
"codelyzer": "~4.3.0",
"copy-webpack-plugin": "^4.6.0",
"html-webpack-plugin": "^2.30.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.5",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^5.4.2",
"raw-loader": "^0.5.1",
"script-ext-html-webpack-plugin": "^1.8.8",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~2.9.2",
"webpack": "4.24.0"
}
}
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"skipLibCheck": true,
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
请帮我解决这个问题
提前致谢
解决方案
试试这些命令看看是否有效
npm uninstall angular-cli -g
npm uninstall angular-cli --save
npm install -g @angular/cli
npm install @angular/cli --save
npm install @angular/compiler-cli --save
推荐阅读
- excel - 查找关键字并复制数据范围
- ruby-on-rails - 查询关联值
- angular - 可观察订阅两次
- mysql - 在 yii2 中运行原始 SQL 时出现 SQL 查询语法错误或访问冲突
- android - 如何使用“异步任务”获取存储在“房间”库中的所有行?
- c# - 从 Revit 加载项调用 Enity Framework 方法会导致 NotSupportedException
- php - Laravel 5.5 无法使用身份验证脚手架登录
- android - 当我想运行应用程序时,Android Studio 没有显示任何设备
- api - 如何通过 Ballerina 中的菜单驱动应用程序调用服务
- bash - Bash:如何在不使用 sed 或 awk 的情况下在 for 循环中获取文件的第 n 行