使用 React 和 Rails 运行服务器时出现问题



我不得不重新安装我编码的 linux VM(出于学校目的(,在重新分叉和克隆我的应用程序后,我无法启动服务器。我已经运行了我相信的必要步骤,创建和迁移了数据库,捆绑了 intall,并安装和重新安装node_modules......我有一个耙子任务,可以同时为我启动 api 和网页。现在如果我耙开始...这是我的错误消息...我已经按照错误消息上的说明进行操作,但没有成功...不确定我是否在这里错过了什么。

rake start
10:12:38 web.1  | started with pid 3280
10:12:38 api.1  | started with pid 3281
10:12:38 web.1  | 
10:12:38 web.1  | > client@0.1.0 start /home/learn/Development/Code/hoop-it-up/client
10:12:38 web.1  | > react-scripts start
10:12:38 web.1  | 
10:12:39 web.1  | 
10:12:39 web.1  | There might be a problem with the project dependency tree.
10:12:39 web.1  | It is likely not a bug in Create React App, but something you need to fix locally.
10:12:39 web.1  | 
10:12:39 web.1  | The react-scripts package provided by Create React App requires a dependency:
10:12:39 web.1  | 
10:12:39 web.1  |   "babel-eslint": "10.0.1"
10:12:39 web.1  | 
10:12:39 web.1  | Don't try to install it manually: your package manager does it automatically.
10:12:39 web.1  | However, a different version of babel-eslint was detected higher up in the tree:
10:12:39 web.1  | 
10:12:39 web.1  |   /home/learn/Development/Code/hoop-it-up/node_modules/babel-eslint (version: 10.0.3) 
10:12:39 web.1  | 
10:12:39 web.1  | Manually installing incompatible versions is known to cause hard-to-debug issues.
10:12:39 web.1  | 
10:12:39 web.1  | If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
10:12:39 web.1  | That will permanently disable this message but you might encounter other issues.
10:12:39 web.1  | 
10:12:39 web.1  | To fix the dependency tree, try following the steps below in the exact order:
10:12:39 web.1  | 
10:12:39 web.1  |   1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
10:12:39 web.1  |   2. Delete node_modules in your project folder.
10:12:39 web.1  |   3. Remove "babel-eslint" from dependencies and/or devDependencies in the package.json file in your project folder.
10:12:39 web.1  |   4. Run npm install or yarn, depending on the package manager you use.
10:12:39 web.1  | 
10:12:39 web.1  | In most cases, this should be enough to fix the problem.
10:12:39 web.1  | If this has not helped, there are a few other things you can try:
10:12:39 web.1  | 
10:12:39 web.1  |   5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
10:12:39 web.1  |      This may help because npm has known issues with package hoisting which may get resolved in future versions.
10:12:39 web.1  | 
10:12:39 web.1  |   6. Check if /home/learn/Development/Code/hoop-it-up/node_modules/babel-eslint is outside your project directory.
10:12:39 web.1  |      For example, you might have accidentally installed something in your home folder.
10:12:39 web.1  | 
10:12:39 web.1  |   7. Try running npm ls babel-eslint in your project folder.
10:12:39 web.1  |      This will tell you which other package (apart from the expected react-scripts) installed babel-eslint.
10:12:39 web.1  | 
10:12:39 web.1  | If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
10:12:39 web.1  | That would permanently disable this preflight check in case you want to proceed anyway.
10:12:39 web.1  | 
10:12:39 web.1  | P.S. We know this message is long but please read the steps above :We hope you find them helpful!
10:12:39 web.1  | 
10:12:39 web.1  | npm ERR! code ELIFECYCLE
10:12:39 web.1  | npm ERR! errno 1
10:12:39 web.1  | npm ERR! client@0.1.0 start: `react-scripts start`
10:12:39 web.1  | npm ERR! Exit status 1
10:12:39 web.1  | npm ERR! 
10:12:39 web.1  | npm ERR! Failed at the client@0.1.0 start script.
10:12:39 web.1  | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
10:12:39 web.1  | 
10:12:39 web.1  | npm ERR! A complete log of this run can be found in:
10:12:39 web.1  | npm ERR!     /home/learn/.npm/_logs/2020-01-10T18_12_39_116Z-debug.log
10:12:40 web.1  | exited with code 1
10:12:40 system | sending SIGTERM to all processes
10:12:40 api.1  | terminated by SIGTERM

根据要求,我在我的包中找到了两个对babel-eslint的引用.lock.json

"babel-eslint": {
"version": "10.0.3",
"resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.0.3.tgz",
"integrity": "sha512-z3U7eMY6r/3f3/JB9mTsLjyxrv0Yb1zb8PCWCLpguxfCzBIZUwy23R1t/XKewP+8mEN2Ck8Dtr4q20z6ce6SoA==",
"requires": {
"@babel/code-frame": "7.5.5",
"@babel/parser": "7.7.7",
"@babel/traverse": "7.7.4",
"@babel/types": "7.7.4",
"eslint-visitor-keys": "1.1.0",
"resolve": "1.12.2"
}
and also here 
"react-scripts": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-3.3.0.tgz",
"integrity": "sha512-hzPc6bxCc9GnsspWqk494c2Gpd0dRbk/C8q76BNQIENi9GMwoxFljOEcZoZcpFpJgQ45alxFR6QaLt+51qie7g==",
"requires": {
"@babel/core": "7.7.4",
"@svgr/webpack": "4.3.3",
"@typescript-eslint/eslint-plugin": "2.15.0",
"@typescript-eslint/parser": "2.15.0",
"babel-eslint": "10.0.3",
etc.......
```

好的,我想出了问题,根目录中新生成的 .env 的 SKIP_PREFLIGHT_CHECK=true 起到了作用,我想因为我的 babel-eslint 版本高于要求,跳过应该没问题,服务器启动没有问题。感谢您的反馈以帮助我解决问题!!

最新更新