运行angular 2 app npm start时出错


编译应用程序时出错 . my @ angular / cli:1.2.4版本@ angular / cli:1.2.4节点:8.11.1 os:win32 x64 @ angular / animations:4.3.6 @ angular / common:4.3.6 @ angular / compiler:4.3 . 6 @ angular / core:4.3.6 @ angular / forms:4.3.6 @ angular / http:4.3.6 @ angular / platform-browser:4.3.6 @ angular / platform-browser-dynamic:4.3.6 @ angular /路由器:4.3.6 @ angular / compiler-cli:4.3.6 @ angular / cli:1.2.4 @ angular / language-service:4.3.6

This is the error while compiling the application.  



ERROR in ./~/css-loader?{"sourceMap":false,"importLoaders":1}!./~/postcss-loader?{"ident":"postcss"}!./src/styles.css
Module build failed: BrowserslistError: Unknown browser query `dead`
    at error (C:\Github project\angForm\node_modules\browserslist\index.js:37:11)
    at C:\Github project\angForm\node_modules\browserslist\index.js:222:9
    at Array.forEach (<anonymous>)
    at browserslist (C:\Github project\angForm\node_modules\browserslist\index.js:196:13)
    at Browsers.parse (C:\Github project\angForm\node_modules\autoprefixer\lib\browsers.js:44:14)
    at new Browsers (C:\Github project\angForm\node_modules\autoprefixer\lib\browsers.js:39:28)
    at loadPrefixes (C:\Github project\angForm\node_modules\autoprefixer\lib\autoprefixer.js:56:18)
    at plugin (C:\Github project\angForm\node_modules\autoprefixer\lib\autoprefixer.js:62:18)
    at LazyResult.run (C:\Github project\angForm\node_modules\postcss\lib\lazy-result.js:274:20)
    at LazyResult.asyncTick (C:\Github project\angForm\node_modules\postcss\lib\lazy-result.js:189:32)
    at LazyResult.asyncTick (C:\Github project\angForm\node_modules\postcss\lib\lazy-result.js:201:22)
    at processing.Promise.then._this2.processed (C:\Github project\angForm\node_modules\postcss\lib\lazy-result.js:228:20)
    at new Promise (<anonymous>)
    at LazyResult.async (C:\Github project\angForm\node_modules\postcss\lib\lazy-result.js:225:27)
    at LazyResult.then (C:\Github project\angForm\node_modules\postcss\lib\lazy-result.js:131:21)
    at C:\Github project\angForm\node_modules\postcss-loader\index.js:129:55
 @ ./src/styles.css 4:14-134
 @ multi ./src/styles.css

ERROR in ./src/app/app.component.css
Module build failed: BrowserslistError: Unknown browser query `dead`
    at error (C:\Github project\angForm\node_modules\browserslist\index.js:37:11)
    at C:\Github project\angForm\node_modules\browserslist\index.js:222:9
    at Array.forEach (<anonymous>)
    at browserslist (C:\Github project\angForm\node_modules\browserslist\index.js:196:13)
    at Browsers.parse (C:\Github project\angForm\node_modules\autoprefixer\lib\browsers.js:44:14)
    at new Browsers (C:\Github project\angForm\node_modules\autoprefixer\lib\browsers.js:39:28)
    at loadPrefixes (C:\Github project\angForm\node_modules\autoprefixer\lib\autoprefixer.js:56:18)
    at plugin (C:\Github project\angForm\node_modules\autoprefixer\lib\autoprefixer.js:62:18)
    at LazyResult.run (C:\Github project\angForm\node_modules\postcss\lib\lazy-result.js:274:20)
    at LazyResult.asyncTick (C:\Github project\angForm\node_modules\postcss\lib\lazy-result.js:189:32)
    at LazyResult.asyncTick (C:\Github project\angForm\node_modules\postcss\lib\lazy-result.js:201:22)
    at processing.Promise.then._this2.processed (C:\Github project\angForm\node_modules\postcss\lib\lazy-result.js:228:20)
    at new Promise (<anonymous>)
    at LazyResult.async (C:\Github project\angForm\node_modules\postcss\lib\lazy-result.js:225:27)
    at LazyResult.then (C:\Github project\angForm\node_modules\postcss\lib\lazy-result.js:131:21)
    at C:\Github project\angForm\node_modules\postcss-loader\index.js:129:55
 @ ./src/app/app.component.ts 18:17-47
 @ ./src/app/app.module.ts
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts

回答(1)

2 years ago

我已将Angular Cli升级到版本6并生成了一个新项目 . 然后尝试在此项目文件夹中使用角度5模板,并获得与运行服务--open相同的错误 . 删除文件“browserslist”(它在src /下)解决了我的问题 .