我在开始我的项目时遇到了一个很大的问题,这个项目是从git克隆的。我尝试写"npm i",用于安装所有的packejest,然后开始写npm,但我看到一个错误。
The react-scripts package provided by Create React App requires a dependency:
"jest": "24.7.1"
Don't try to install it manually: your package manager does it automatically.
However, a different version of jest was detected higher up in the tree:
/Users/nazarromanchuk/node_modules/jest (version: 24.9.0)
Manually installing incompatible versions is known to cause hard-to-debug issues.
...我知道要删除node_modules,package-lock.json和white一次"npm i“-同样的错误
我的package.json外观:
{
"name": "interview-question",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-scripts": "3.0.1"
},
"dependencies": {
"date-fns": "^1.28.0",
"dayjs": "^1.8.16",
"faker": "^4.1.0",
"lodash": "^4.17.15",
"node-sass": "^4.12.0",
"react": "^16.9.0",
"react-compound-timer": "^1.1.5",
"react-countdown-now": "^2.1.1",
"react-dom": "^16.9.0",
"react-loader-spinner": "^3.1.4",
"react-redux": "^7.1.0",
"react-spinners": "^0.6.1",
"redux": "^4.0.1",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0",
"styled-components": "^4.3.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}我也试着在“依赖”jest版本24.07.1中写,也删除了node_modules,package-lock.json,但是它没有改变任何东西--同样的错误(还有,我是用SKIP_PREFLIGHT_CHECK=true添加的.env文件,但是它也没有帮助修复我的错误
有人能帮帮我吗?谢谢!
发布于 2019-09-15 06:50:02
我想如果你仔细看看这一行:
/Users/nazarromanchuk/node_modules/jest它是您的Home目录中的目录。也许你错误地在你的主目录中运行了npm init?您可以检查/Users/nazarromanchuk/并删除package.json和node_modules文件夹吗?然后在interview-questions模块中更改目录(cd ),然后运行npm i或尝试使用yarn
发布于 2021-05-10 16:24:18
尝试将系统中的jest降级到项目的版本。你可以在这里找到它:
/Applications/node_modules/package.json在节点模块目录中:npm install jest@24.7.1 (项目版本)
https://stackoverflow.com/questions/57937127
复制相似问题