【问题标题】:react npm run build failing but run start works反应 npm run build 失败但 run start 有效
【发布时间】:2021-03-26 15:33:40
【问题描述】:

我的应用程序一直无法创建 npm build,它抛出了错误

> react-scripts build

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

Cannot read property 'toLowerCase' of undefined        
CompileError: Begins at CSS selector input.advert:focus


npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! public@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the public@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:

调试这个对我来说有点困难,因为我已经删除了我所有的 toLowerCase 方法,即使搜索项目全局返回 0 找到,但我仍然得到这可能是模块正在使用还是什么?

我的包裹有

"@ckeditor/ckeditor5-build-classic": "^20.0.0",
    "@ckeditor/ckeditor5-react": "^2.1.0",
    "axios": "^0.18.0",
    "chart.js": "^2.9.4",
    "node-sass": "^4.14.1",
    "qrcode.react": "^1.0.0",
    "query-string": "^6.13.7",
    "react": "^16.14.0",
    "react-addons-css-transition-group": "^15.6.2",
    "react-chartjs-2": "^2.11.1",
    "react-dnd": "^5.0.0",
    "react-dom": "^16.14.0",
    "react-dropzone": "^11.2.4",
    "react-image-crop": "^8.6.6",
    "react-image-magnify": "^2.7.4",
    "react-redux": "^7.2.2",
    "react-router-dom": "^5.2.0",
    "react-scripts": "^3.4.4",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0",
    "tiny-slider-react": "^0.4.0",
    "tsutils": "^3.17.1",
    "typescript": "^3.9.7",
    "underscore": "^1.12.0"

希望能帮助您摆脱这种情况

【问题讨论】:

  • 您是否尝试在 node_modules 中搜索?我使用 VS 代码,默认情况下它会忽略搜索该文件夹
  • 我有,但它们有一种语气,但很清楚我无法阅读每个模块中的所有代码,如果有人遇到过这种情况或知道我提供的模块中的哪个模块可以,则需要帮助可能是行为不端,所以我只能改变这一点

标签: reactjs npm


【解决方案1】:

由于某种原因我也不太明白,问题不在于 JavaScript 而是 CSS,

input.advert:focus {
    border: 0px;
    border-bottom: 1px solid lightgrey;
    box-shadow: none;
    border-color: none;
}

上面的 CSS 似乎不允许构建包,当我删除它时,编译现在通过

也许可以解释或不支持 :focus 可能是因为 :active 具有相同的样式但工作正常

【讨论】:

    猜你喜欢
    • 2021-03-11
    • 2020-12-31
    • 2018-09-19
    • 1970-01-01
    • 2020-09-14
    • 2020-10-26
    • 2021-02-01
    • 2017-10-05
    • 2020-11-28
    相关资源
    最近更新 更多