我的create-react-app无法构建,出现此错误:
./src/index.css
Module build failed: BrowserslistError: Unknown browser query `dead`
at Array.forEach (<anonymous>)
我检查了package-lock.json并更新了所有依赖于浏览器列表的软件包,但是其中一些没有更新到v3以上,我认为这是问题所在,它们是:
-自动前缀 -babel预设环境 -babel预设反应应用 -postcss-merge-rules
我可以只删除这些软件包吗?尽管其他软件包也依赖于它们,但是我还是束手无策,该应用程序运行良好,但无法构建,因此肯定无法在开发服务器上正常工作吗?
我的package.json是:
{
"name": "dashboard",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "latest",
"@shopify/polaris": "latest",
"autoprefixer": "^9.5.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react-app": "^7.0.2",
"browserslist": "^4.5.2",
"caniuse-api": "^3.0.0",
"chalk": "^2.0.1",
"css-loader": "^2.1.1",
"cssnano": "^4.1.10",
"dns": "^0.2.2",
"module": "^1.2.5",
"mongodb": "^3.1.10",
"mongoose": "^5.4.3",
"postcss-merge-rules": "^4.0.3",
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-router": "latest",
"react-router-dom": "^4.3.1",
"react-scripts": "^1.1.4",
"serve": "^10.1.2",
"start": "^5.1.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"devDependencies": {
"babel-jest": "^23.6.0",
"enzyme": "^3.7.0",
"enzyme-adapter-react-16": "^1.7.0",
"enzyme-to-json": "^3.3.4",
"jest": "^23.6.0"
},
"jest": {
"snapshotSerializers": [
"enzyme-to-json/serializer"
]
}
}
答案 0 :(得分:1)
当您说您经历了程序包锁定并更新了版本时,确定要这样做后再次运行npm install
吗?
您可以尝试运行npm update
来查看是否可以解决您的问题。
如果仍然不能解决问题,则可以运行npm ls
列出所有程序包及其依赖关系,以尝试查找与先前版本的BrowserList相关的程序包,检查版本。该软件包,以检查是否可以更新它,如果不能更新,则可能需要与该软件包的所有者联系