初始化本地安装的 ESLint 后,节点module消失

IT技术 reactjs react-native eslint
2021-04-29 19:26:13

在我最初的 React 应用程序中(由react-native init project_name)。在我的项目文件夹中,我通过yarn add eslint --dev. 然后我通过./node_modules/.bin/eslint --init(使用Airbnb样式指南、使用ReactJSON配置文件格式)初始化我的配置安装的 eslint 在./node_modules/.bin文件夹中消失了

初始化前: ls ./node_modules/.bin acorn eslint jest-runtime node-pre-gyp semver atob esparse js-yaml nopt sshpk-conv babylon esvalidate jsesc pegjs sshpk-sign color-support handlebars json5 rc sshpk-verify detect-libc image-size loose-envify react-native uglifyjs envinfo import-local-fixture metro regjsparser uuid escodegen is-ci mime rimraf watch esgenerate jest mkdirp sane which

初始化后: ls ./node_modules/.bin babylon esparse esvalidate jsesc loose-envify semver

我错过了什么?

平台:macOS,react-native-cli:2.0.1,react-native:0.54.2

1个回答

这是由 NPM 5 中的一个错误引起的,该错误npm install将删除几乎所有的依赖项。这是相关的问题。即使您正在使用yarn,eslint也会npm在幕后使用来安装它需要的依赖项,因此会遇到上述错误。

这最近在npm >= 5.7.1 中得到了修复,因此您需要升级npm然后重新安装所有module。

就个人而言,我只是从头开始重新创建整个项目,因为您似乎还没有做任何事情。这比试图解决问题要简单得多。

通过升级,您还可以react-native-cli像 v5.7.1 之前一样无错误地使用,您实际上应该使用 NPM 4。请参阅此错误。