You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.
When I try to use tplink-cloud-api package example in the README, I get this error when running my node script.
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: .../node_modules/axios-curlirize/src/main.js
require() of ES modules is not supported.
require() of .../node_modules/axios-curlirize/src/main.js from .../node_modules/tplink-cloud-api/distribution/tplink.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename main.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from .../node_modules/axios-curlirize/package.json.
If I clone this package to my machine and build it by myself and use that build, everything works fine.
The text was updated successfully, but these errors were encountered:
The way node handled ES modules has been awful, if any dependency switches to it without changing the major version, npm will automatically install it, which doesn't work, the axios dev was one of these people, so even though there was no major version change, there's a breaking change, so it's up to everyone depending on axios to either update to use ES modules, forcing everyone using those packages to do the same, or downgrade to the version before the change, which should have been a major version change like node-fetch did.
People can use npm i [email protected] until adumont either updates and makes us update/downgrade or downgrades axios in tplink-cloud-api
I was trying to use this as a function on Vercel and ran into this issue. Presuming that it's the require statements instead of the use of imports that are in the npm distribution, is this something that can be fixed anytime soon?
Here's the error I see in the Vercel console.
2022-12-19T23:16:30.129Z undefined ERROR Error [ERR_REQUIRE_ESM]: require() of ES Module /var/task/node_modules/tplink-cloud-api/node_modules/axios-curlirize/src/main.js from /var/task/node_modules/tplink-cloud-api/distribution/tplink.js not supported.
Instead change the require of main.js in /var/task/node_modules/tplink-cloud-api/distribution/tplink.js to a dynamic import() which is available in all CommonJS modules.
at Object. (/var/task/node_modules/tplink-cloud-api/distribution/tplink.js:74:41)
at Object. (/var/task/api/switch/toggle.js:8:23)
at async Promise.all (index 0)
at async getListener (/var/task/___vc/__launcher.js:37:11) {
code: 'ERR_REQUIRE_ESM'
}
RequestId: d156f016-f09b-49c9-a917-ea04950e444a Error: Runtime exited with error: exit status 1
Runtime.ExitError
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When I try to use
tplink-cloud-api
package example in the README, I get this error when running my node script.If I clone this package to my machine and build it by myself and use that build, everything works fine.
The text was updated successfully, but these errors were encountered: