[英]Error importing npm module in react-native
Currently creating an android app. 当前正在创建一个android应用。 I am simply trying to import the
spotify-web-api-node
module. 我只是试图导入
spotify-web-api-node
模块。
One line so far in my index.android.js
to do this: 到目前为止,在我的
index.android.js
可以做到这一点:
import SpotifyWebApi from 'spotify-web-api-node';
When I go to load the JS into my emulator I get the follow error: 当我将JS加载到模拟器中时,出现以下错误:
602/603Error while persisting cache: SyntaxError /path/to/the/project/node_modules/restler/lib/multipartform.js: Invalid number (112:35)
I am using a mac, this occurs for android (have not tried ios yet). 我正在使用Mac,这是针对android系统(尚未尝试使用ios)。
react-native -v
= react-native-cli: 0.1.10 react-native: 0.21.0
react-native -v
= react-native-cli: 0.1.10 react-native: 0.21.0
Is this module surely not compatible with react-native or is there an edit I may need to make within restler to make it compatible? 该模块是否肯定与react-native不兼容,或者我可能需要在restler中进行编辑以使其兼容? I see on the line it is complaining about, it is attempting to open/use the file system.
我在网上抱怨它,它正在尝试打开/使用文件系统。
Line that is in the error description: 错误描述中的行:
fs.open(this.value.path, "r", 0666, function (err, fd) {
First of all, I have never used this API. 首先,我从未使用过此API。 But after reading readme.md of
spotify-web-api-node
I found spotify-web-api-js 但是在阅读了
spotify-web-api-node
readme.md之后,我发现了spotify-web-api-js
I assume you want to fire queries through spotify's API and display the results in your app. 我假设您想通过Spotify的API触发查询并在您的应用中显示结果。 I'd suggest you to use
spotify-web-api-js
instead of spotify-web-api-node
我建议您使用
spotify-web-api-js
而不是spotify-web-api-node
You can call fetch()
in your react-native app and use their API. 您可以在本机应用程序中调用
fetch()
并使用其API。 Please let me know if this works. 请让我知道是否可行。 So that programmers who are facing the same problem will have an answer on this thread.
这样,面临相同问题的程序员就可以在此线程上找到答案。 Good luck!
祝好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.