【问题标题】:React App failed to compile after installReact App 安装后编译失败
【发布时间】:2020-10-10 09:09:26
【问题描述】:

运行安装脚本后,服务器启动并提供在“编译失败行”之后显示相同文本的页面。

我正在运行 Windows 10 并且自动更新今天刚刚更新了我的电脑,就在我进行 create-react-express 安装之前。


PS H:\mern-passport> npm start

> mern@1.0.0 start H:\mern-passport
> if-env NODE_ENV=production && npm run start:prod || npm run start:dev


> mern@1.0.0 start:dev H:\mern-passport
> concurrently "nodemon --ignore 'client/*'" "npm run client"

[0] [nodemon] 1.19.4
[0] [nodemon] to restart at any time, enter `rs`
[0] [nodemon] watching dir(s): *.*
[0] [nodemon] watching extensions: js,mjs,json  
[0] [nodemon] starting `node server.js`
[0] API server now on port 3001!
[1] 
[1] > mern@1.0.0 client H:\mern-passport
[1] > cd client && npm run start
[1]
[1] 
[1] > mern@0.1.0 start H:\mern-passport\client
[1] > react-scripts start
[1]
[1] Starting the development server...
[1]
[1] Failed to compile.
[1]
[1] ./src/index.css (./node_modules/css-loader??ref--6-oneOf-3-1!./node_modules/postcss-loader/src??postcss!./src/index.css)
[1] Error: Package exports for 'H:\mern-passport\client\node_modules\autoprefixer\node_modules\kleur' do not define a valid './colors' target
[0] Error: ENOENT: no such file or directory, stat 'H:\mern-passport\client\build\index.html'
[0] Error: ENOENT: no such file or directory, stat 'H:\mern-passport\client\build\index.html'

【问题讨论】:

标签: node.js reactjs npm mern


【解决方案1】:

似乎是 autoprefixer 最新版本的问题。我提到了https://github.com/postcss/autoprefixer/issues/1328 并尝试在我的项目中降级 autoprefixer,它现在可以工作了。 试试:

npm install autoprefixer@9.8.0

编码愉快!

【讨论】:

  • 赢家!谢谢@Krishna Majgaonkar!
  • 不错的一个。我的回答有点不相关,但它解决了它。
  • 这也解决了与“colorette”包相同的问题,谢谢!
  • 是的,对于 colorette 包,我降级到 1.2.0 来解决这个问题。
【解决方案2】:

我也遇到过这个问题。而且好像autoprefixer版本有问题,所以我改了版本。

npm install autoprefixer@9.8.0

我试过了,效果很好。

【讨论】:

    【解决方案3】:

    我也遇到了这个问题。我安装了 yarn 并使用 npx create-react-app 命令创建了一个新项目,这解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-01
      • 2021-06-14
      • 1970-01-01
      相关资源
      最近更新 更多