初始化本地安装的 ESLint 后节点模块消失

Node modules disappear after initializing the localy installed ESLint

在我最初的 React 应用程序中(由 react-native init project_name 创建)。在我的项目文件夹中,我通过 yarn add eslint --dev 在本地安装我的 ESLint。 然后我通过 ./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

这是由 NPM 5 中的错误引起的,其中 npm install 将删除几乎所有的依赖项。 This was the relevant issue. 即使您正在使用 yarneslint 也会在后台使用 npm 来安装它需要的依赖项,因此 运行 会进入上述错误.

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

就个人而言,我只是从头开始重新创建整个项目,因为看起来您还没有做任何事情。这比尝试修复问题要简单得多。

通过升级,您还可以使用 react-native-cli 而不会出错,就像 v5.7.1 之前一样,您实际上应该使用 NPM 4。See this bug.