Can't import the named export 'deferred' from non EcmaScript module (only default export is available)
See original GitHub issueDescribe the bug
I am trying to use it in AWS Lambda. The tool chain I am using is serverless and serverless-webpack plugin. Webpack complains about “Can’t import … from non EcmaScript module” in Node 14 environment:
[2022-05-18T10:10:53.414Z] ERROR in ./node_modules/axios-cache-interceptor/dist/index.mjs 1:1278-1288
[2022-05-18T10:10:53.414Z] Can't import the named export 'deferred' from non EcmaScript module (only default export is available)
[2022-05-18T10:10:53.414Z] @ ./api.ts
[2022-05-18T10:10:53.414Z] @ ./handler.ts
[2022-05-18T10:10:53.414Z]
[2022-05-18T10:10:53.414Z] ERROR in ./node_modules/axios-cache-interceptor/dist/index.mjs 1:6483-6489
[2022-05-18T10:10:53.414Z] Can't import the named export 'hash' from non EcmaScript module (only default export is available)
[2022-05-18T10:10:53.414Z] @ ./api.ts
[2022-05-18T10:10:53.414Z] @ ./handler.ts
[2022-05-18T10:10:53.414Z]
[2022-05-18T10:10:53.414Z] ERROR in ./node_modules/axios-cache-interceptor/dist/index.mjs 1:485-492
[2022-05-18T10:10:53.414Z] Can't import the named export 'parse' from non EcmaScript module (only default export is available)
[2022-05-18T10:10:53.414Z] @ ./api.ts
[2022-05-18T10:10:53.414Z] @ ./handler.ts
[2022-05-18T10:10:53.414Z]
[2022-05-18T10:10:53.414Z] Error ---------------------------------------------------
[2022-05-18T10:10:53.414Z]
[2022-05-18T10:10:53.414Z] Error: Webpack compilation error, see stats above
[2022-05-18T10:10:53.414Z] at /home/ec2-user/workspace/services_feature_cache-term-info/statement/stmt-results/node_modules/serverless-webpack/lib/compile.js:37:15
[2022-05-18T10:10:53.414Z] at arrayEach (/home/ec2-user/workspace/services_feature_cache-term-info/statement/stmt-results/node_modules/serverless-webpack/node_modules/lodash/lodash.js:530:11)
[2022-05-18T10:10:53.414Z] at Function.forEach (/home/ec2-user/workspace/services_feature_cache-term-info/statement/stmt-results/node_modules/serverless-webpack/node_modules/lodash/lodash.js:9410:14)
[2022-05-18T10:10:53.414Z] at /home/ec2-user/workspace/services_feature_cache-term-info/statement/stmt-results/node_modules/serverless-webpack/lib/compile.js:34:7
[2022-05-18T10:10:53.414Z] at tryCatcher (/home/ec2-user/workspace/services_feature_cache-term-info/statement/stmt-results/node_modules/bluebird/js/release/util.js:16:23)
BTW, in tsconfig.json, “target” and “module” decide the compatibility level of your npm package. If you specify ESNext, that means your package can only be guaranteed to work in the environment that supports all features of ESNext. I usually set that to ES2017 so that my package can work in Node 10+.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Can't import the named export XXXX from non EcmaScript ...
the solution is to make sure that you have a webpack.config.js file in the root of your project directory that looks something like...
Read more >Can't import the named export 'Button' from non EcmaScript ...
Can't import the named export 'BaseMessageSignerWalletAdapter' from non EcmaScript module (only default export is available) #268.
Read more >Can't import the named export from non EcmaScript module
Hi My site name is stupefied-lamarr-20c8d9 On the server side of my app I have lambda functions and within those I'm using apollo-server-lambda...
Read more >"Can't import the named export from non EcmaScript module ...
KJS: "Can't import the named export from non EcmaScript module (only default export is available)" with react-map-gl-draw external interface. Relates to 1.
Read more >can't import the named export from non ecmascript module ...
This means your bundler resolves .mjs files, however it doesn't know that they are ESM modules. On webpack, you can add the following...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Found a workaround:
Thanks, this means a lot!