问题描述
在我的初始react应用程序中(由 react-native init project_name
创建)。在我的项目文件夹中,通过 yarn add eslint --dev
在本地安装我的ESLint。
然后我通过初始化我的配置。/node_modules/.bin/eslint--init
(使用 Airbnb
样式指南,使用 React
和 JSON
配置文件格式)。安装的eslint消失在 ./ node_modules / .bin
文件夹中。
In my initial react application (created by react-native init project_name
). In my project folder, I install my ESLint locally by yarn add eslint --dev
.Then I initialize my configuration by ./node_modules/.bin/eslint --init
(with Airbnb
style guide, using React
, and JSON
configuration file format). The installed eslint is disappeared in ./node_modules/.bin
folder.
初始化之前:
ls ./node_modules/.bin
橡子eslint开玩笑的运行时node-gyp semver
atob esparse js-yaml nopt sshpk-conv
babylon esvalidate jsesc pegjs sshpk-sign
颜色支持把手json5 rc sshpk-verify
detect-libc image-size宽松-envify react-native uglifyjs
envinfo import-local-fixture Metro regjsparser uuid
escodegen is-ci mime rimraf手表
产生开玩笑的mkdirp健全,
初始化后:
ls ./node_modules/.bin
巴比伦esparse esvalidate jsesc松散envify semver
我想念什么?
平台:macOS,react-native-cli:2.0.1,react-native:0.54.2
Platforms: macOS, react-native-cli: 2.0.1, react-native: 0.54.2
推荐答案
这是由NPM 5中的一个错误引起的,其中 npm install
会删除几乎所有依赖项。 即使您使用的是 yarn
, eslint
将在内部使用 npm
来安装所需的依赖项,从而会遇到上述错误。
This is caused by a bug in NPM 5 where npm install
will delete almost all of your dependencies. This was the relevant issue. Even though you are using yarn
, eslint
will use npm
under the hood to install the dependencies it needs, and thus will run into the aforementioned bug.
该问题最近已在 npm> = 5.7.1 中修复,因此您需要升级 npm
,然后重新安装所有模块。
This has very recently been fixed in npm >= 5.7.1, so you will need to upgrade npm
and then reinstall all of your modules.
我个人而言,我只是从以下位置重新创建整个项目从头开始,因为您似乎尚未完成任何操作。
通过升级,您还可以使用 react-与v5.7.1之前一样,native-cli
没有错误,实际上您应该使用NPM4。
By upgrading, you will also be able to use react-native-cli
without error as prior to v5.7.1, you were actually supposed to use NPM 4. See this bug.
这篇关于初始化本地安装的ESLint后,节点模块消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!