我从 Github 克隆了我已经在 Github Pages 上运行的 React-Typescript 应用程序,并希望进行一些更改。我运行 npm install 并安装了所有依赖项,但是当我运行 npm start 时,出现此错误;
我不知道 chokidar 是什么,我看了一点,我认为它与我的项目无关。我仍然尝试 npm install chokidar 并且我遇到了另一个这样的错误;
也试过npm audit fix
以及。修复了一些东西,但没有任何改变。
所以我无法打开开发服务器。此外,这是 package.json 文件;
// package.json
{
"name": "panflix",
"homepage": "https://absolutezero13.github.io/meerkast/",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/enzyme": "^3.10.8",
"@types/jest": "^26.0.15",
"@types/node": "^12.0.0",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@types/redux-devtools": "^3.0.47",
"axios": "^0.21.1",
"enzyme": "^3.11.0",
"firebase": "^8.2.7",
"gh-pages": "^3.1.0",
"history": "^4.10.1",
"react": "^17.0.1",
"react-bootstrap": "^1.5.0",
"react-dom": "^17.0.1",
"react-redux": "^7.2.2",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.2",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0",
"typescript": "^4.1.2",
"web-vitals": "^1.0.1"
},
"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"
]
},
"devDependencies": {
"@types/react-redux": "^7.1.16",
"@types/react-router-dom": "^5.1.7"
}
}
我试过 npm install -g chokidar
它已安装。但是我收到了与之前相同的错误“没有可用的 chokidar 版本”。其他 react 项目工作正常。
最佳答案
我遇到过同样的问题。对我有用的是强制更新本地 npm 包:
npm update --force
前$ npm list chokidar
pwa-react-showcase@0.1.0
└─┬ react-scripts@4.0.3
└─┬ webpack-dev-server@3.11.1
└── chokidar@2.1.8
后$ npm list chokidar
pwa-react-showcase@0.1.0
└─┬ react-scripts@4.0.3
├─┬ webpack-dev-server@3.11.1
│ └── chokidar@2.1.8
└─┬ webpack@4.44.2
└─┬ watchpack@1.7.5
├── chokidar@3.5.1
└─┬ watchpack-chokidar2@2.0.1
└── chokidar@2.1.8
更新我们发现 NPM 7 是问题所在。降级到 NPM 6.14.12 无需任何更改。
关于reactjs - react npm 开始不工作 : 'No version of chokidar available' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66734503/