0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[React Native] react-native-xml2jsをインストールしてエラーが出たときの対処法

Last updated at Posted at 2022-06-26

環境

  • MacBook Air (M1)
  • macOS Monterey 12.3
  • Node.js v17.8.0
  • Expo 44.0.0

react-native-xml2js とは

xml2jsをReact Native用にフォークしたもの。

This is a fork of node-xml2js to support react-native.

引用:

xml2js とは

XMLをJavaScriptオブジェクトに変換するnodeモジュール。

Ever had the urge to parse XML? And wanted to access the data in some sane, easy way? Don't want to compile a C parser, for whatever reason? Then xml2js is what you're looking for!

引用:

react-native-xml2jsをインストールする

npm i react-native-xml2js

VSCodeでエラーが出て、予測変換が表示されなくなった。
そして、以下を実行しろと言われた。

npm i --save-dev @types/react-native-xml2js

実行したところ、エラーが表示された。

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@types%2freact-native-xml2js - Not found
npm ERR! 404 
npm ERR! 404  '@types/react-native-xml2js@*' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

型定義のファイルが存在しないみたい。

@types/xml2jsをインストールする

xml2jsの型定義のファイルは存在した。
参考:@types/xml2js - npm

npm i @types/xml2js

名前を変更する。

cp -r node_modules/@types/xml2js/ node_modules/@types/react-native-xml2js/

エラーが消えて、予測変換が表示されるようになった。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?