Closed drakonkat closed 2 years ago
Latest webtorrent-hybrid is an ES module
Must be imported as such
On 31/12/2021, at 9:25 AM, Drakonkat @.***> wrote:
What version of this package are you using? 5.0.1
What operating system, Node.js, and npm version? Nodejs: 14.17.6 Npm: 6.14.15 SO: Windows 10
What happened? Give me error when i change from const WebTorrent = require('webtorrent'); to const WebTorrent = require('webtorrent-hybrid');
What did you expect to happen? Does not give error but works in hybrid way
Log of the error: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: D:\Project\FE\webtorrent-express-api\node_modules\webtorrent-hybrid\index.js require() of ES modules is not supported. require() of D:\Project\FE\webtorrent-express-api\node_modules\webtorrent-hybrid\index.js from D:\Project\FE\webtorrent-express-api\routes\torrent.js is an ES module file as it is a .js file whose nearest parent package.json contain s "type": "module" which defines all .js files in that package scope as ES modules. Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from D:\Project\FE\webtorrent-express-api\node_modules\webtorrent-hybrid\package.json.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.
Sorry, i didn't undestand do you exptect that is working? because i have the latest version but continue to give me the error "[ERR_REQUIRE_ESM]". Maybe i'm missing something about expressjs or something?
WIth the version 4.1.3 everythings works, but there is a way to support old require in the new version?
how did you solve this?
how did you solve this?
You can use dynamic import
What version of this package are you using? 5.0.1
What operating system, Node.js, and npm version? Nodejs: 14.17.6 Npm: 6.14.15 SO: Windows 10
What happened? Give me error when i change from
const WebTorrent = require('webtorrent');
toconst WebTorrent = require('webtorrent-hybrid');
What did you expect to happen? Does not give error but works in hybrid way
Log of the error:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: D:\Project\FE\webtorrent-express-api\node_modules\webtorrent-hybrid\index.js require() of ES modules is not supported. require() of D:\Project\FE\webtorrent-express-api\node_modules\webtorrent-hybrid\index.js from D:\Project\FE\webtorrent-express-api\routes\torrent.js is an ES module file as it is a .js file whose nearest parent package.json contain s "type": "module" which defines all .js files in that package scope as ES modules. Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from D:\Project\FE\webtorrent-express-api\node_modules\webtorrent-hybrid\package.json.