gpt4 book ai didi

node.js - 为什么我可以构建我的 React 应用程序但无法启动它

转载 作者:行者123 更新时间:2023-12-05 04:46:13 25 4
gpt4 key购买 nike

rehype-katex5.0.0 升级到 6.0.1 后,当我运行 yarn start ,我得到了:

./node_modules/hast-util-to-text/index.js 363:65
Module parse failed: Identifier directly after number (363:65)
File was processed with these loaders:
* ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| // break is the zero-width space character (U+200B), then the break is
| // removed, leaving behind the zero-width space.
> if (lines[index].charCodeAt(lines[index].length - 1) === 0x20_0b
| /* ZWSP */
| || index < lines.length - 1 && lines[index + 1].charCodeAt(0) === 0x20_0b

但它在 codesandbox 中工作正常, yarn build 也可以。我该如何解决这个问题?

我的 package.json:

{
"name": "blog",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.0.0",
"@testing-library/user-event": "^13.2.1",
"gh-pages": "^3.2.3",
"pubsub-js": "^1.9.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-helmet": "^6.1.0",
"react-markdown": "^7.0.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"react-syntax-highlighter": "^15.4.4",
"rehype-katex": "^6.0.1", // Upgrade
"rehype-raw": "^6.0.0",
"remark-gfm": "^2.0.0",
"remark-math": "^5.0.0",
"web-vitals": "^2.1.0"
},
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"homepage": "https://xxx.github.io"
}
  • 操作系统:Linux
  • yarn :v1.22.11
  • nodejs: v16.6.2

最佳答案

我遇到了完全相同的问题,并通过以下 SO POST 解决了这个问题:https://stackoverflow.com/a/67574280/16766691

只需转到项目根文件夹下的 package.json,

替换

"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}

  "browserslist": [
">0.2%",
"not dead",
"not op_mini all"
]

然后重新编译你的项目。

关于node.js - 为什么我可以构建我的 React 应用程序但无法启动它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68904475/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com