reactjs - 浏览器列表错误: Unknown browser query `dead` in React/Express App

标签 reactjs npm webpack dependencies package.json

当我运行“npm start”时,应用程序启动得很好,但“npm run build”在终端中显示以下消息:

> workout_tracker@0.1.0 build /Users/*******/mern-workout/client
> react-scripts build

Creating an optimized production build...
Failed to compile.

./src/Components/UI/Spinner/Spinner.module.css
Module build failed: BrowserslistError: Unknown browser query `dead`
    at Array.forEach (<anonymous>)


npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! workout_tracker@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the workout_tracker@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional 
logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/*******/.npm/_logs/2018-10-22T23_21_04_691Z-debug.log

我已经搜索过,但是,唯一的解决方案似乎是针对使用 Angular 且 Bootstrap 版本存在问题的人。我没有在我的应用程序中使用 Bootstrap。

我尝试从 browserslist 数组中删除“not dead”只是为了看看会发生什么,我得到了这个:

Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file: 

    ./node_modules/query-string/index.js:8 

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! workout_tracker@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the workout_tracker@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/******/.npm/_logs/2018-10-22T23_41_55_488Z-debug.log

这是我的 package.json 文件:

 {
  "name": "workout_tracker",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "axios": "^0.18.0",
    "browserslist": "^4.3.1",
    "cssnano": "^4.1.7",
    "firebase": "^5.3.0",
    "jw-paginate": "^1.0.2",
    "jw-react-pagination": "^1.0.7",
    "normalize.css": "^8.0.0",
    "query-string": "^6.2.0",
    "random-id": "0.0.2",
    "react": "^16.5.2",
    "react-dom": "^16.5.2",
    "react-headroom": "^2.2.2",
    "react-icons-kit": "^1.1.6",
    "react-redux": "^5.0.7",
    "react-router-dom": "^4.3.1",
    "react-scripts-cssmodules": "^1.1.10",
    "react-swipe-to-delete-component": "^0.3.4",
    "react-swipeout": "^1.1.1",
    "redux": "^4.0.0",
    "redux-thunk": "^2.3.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "devDependencies": {
    "css-loader": "^1.0.0",
    "redux-devtools-extension": "^2.13.5",
    "webpack": "^3.8.1"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "proxy": "http://localhost:4000"
}

最佳答案

使用 React 时,请查看您的 package.json。您可能会发现其中添加了以下内容。

  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]

删除“not dead”,并再次运行yarn run build。为我解决了这个问题。

关于reactjs - 浏览器列表错误: Unknown browser query `dead` in React/Express App,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52939103/

相关文章:

javascript - 在多模块项目中使用自定义 React Hook 进行 Jest 测试时出错

reactjs - 配置 Cypress、cypress-react-unit-test 和 React

javascript - 带有连字符的 Webpack 外部模块名称

javascript - React Native - 可按下 - 无法运行示例代码

reactjs - 如何通过单击其他元素来添加和删除元素的类?在 React-redux 中

typescript - 如何阻止从不应从文件夹导入的 vscode typescript 文件?

javascript - 有没有办法在 package.json 中创建一个 npm 库并在安装时运行它的构建过程?

javascript - 使用 Axios 的 Amazon S3 远程文件上传

node.js - 客户端和服务器端之间的 Socket.io 连接失败(Reacr/Node.js)

reactjs - 使用 React Navigation 在 React Native 应用程序中共享状态