简体   繁体   中英

Node.js - ES6 module import to Node.js 'require'

What is the Node.js 'require' equivalent to the following ES6 import?

import RNFetchBlob from 'react-native-fetch-blob'

Thank you

There's no default export in require so you don't have an exact equivalent.

The practice with node modules when you have only one value to export is to make it the module exports:

module.exports = ...

In such a case, you'll be able to import using

var RNFetchBlob = require('react-native-fetch-blob');

Solution

I got it working with:

var RNFetchBlob = require('react-native-fetch-blob').default;

For more details, check out this .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM