Node.js模块正在寻找节点模块而不是node_modules

问题描述 投票:-1回答:1

根据here的说明,我有以下内容:

const Pubgapi = require('pubg-api');
const apiInstance = new Pubgapi('api-key');

出于某种原因,当我运行它时,控制台说无法解析路径,但它正在寻找一个我没有的节点模块。这是我试图使用的API包装器。什么可能导致它给我这个错误?

我按照说明进行了npm安装,在上述声明之前没有其他任何内容。

错误信息:

Unable to resolve ../node-modules/pubg-api" from ".//components/Main.js`: The module `../node-modules/pubg-api` could not be found"

我检查了node_modules文件夹。确实是pubg-api,而不是pubg_api。要求pubg_api给我这个错误。

Enter image description here

node.js api react-native npm node-modules
1个回答
0
投票

此错误可能与您尝试安装depends on的库的HTTPS库有关。 Node.js库与react-native不兼容,因为它不在Node.js平台上运行。

要解决这个问题,你可以尝试使用react-native-http库,但我之前没有尝试过使用它,所以我不确定它是否会起作用。

© www.soinside.com 2019 - 2024. All rights reserved.