安装React时遭遇严重阻碍,求助解决jest-worker报错问题
解决jest-worker模块编译错误的步骤
错误详情
/node_modules/react-scripts/node_modules/eslint-webpack-plugin/node_modules/jest-worker/build/index.js:110_ending;
^
已尝试彻底删除并重装npm、node等相关组件,但错误仍反复出现。
具体解决步骤
- 清理npm缓存:
npm cache clean --force - 删除项目根目录下的
node_modules文件夹以及package-lock.json(使用yarn则删除yarn.lock) - 手动删除嵌套的有问题的jest-worker依赖目录:
- macOS/Linux:
rm -rf node_modules/react-scripts/node_modules/eslint-webpack-plugin/node_modules/jest-worker - Windows:
rmdir /s /q node_modules\react-scripts\node_modules\eslint-webpack-plugin\node_modules\jest-worker
- macOS/Linux:
- 重新执行依赖安装:
npm install - 如果以上步骤无效,尝试升级react-scripts到最新版本:
npm install react-scripts@latest - 最后检查Node.js版本是否为LTS版本(推荐16.x/18.x),版本不兼容也可能导致这类依赖编译问题
内容的提问来源于stack exchange,提问作者Kevin Scott
相关产品推荐
相关产品推荐

