Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot require() package #39

Closed
IgnacioPinedo opened this issue Dec 14, 2022 · 7 comments
Closed

Cannot require() package #39

IgnacioPinedo opened this issue Dec 14, 2022 · 7 comments

Comments

@IgnacioPinedo
Copy link
Contributor

IgnacioPinedo commented Dec 14, 2022

I've used nodecredstash@2.0.2 for a while now, but wanted to upgrade to leverage the aws-sdk v3 separate modules and decreased node_modules folder size. Unfortunately the repo I use it in doesn't support ES6 and I can't require() the package. This is the error I'm seeing:

/.../node_modules/nodecredstash/src/index.js:13
import { KMSClient } from '@aws-sdk/client-kms';
^^^^^^

SyntaxError: Cannot use import statement outside a module

It would be nice if the package was imported using CommonJS instead of ES6, that way it could be used in both ES6 and non-ES6 repos.

To reproduce you only need to try and require() the package in any file. An easy way to do this, is by going to the npm package RunKit and clicking run.

@IgnacioPinedo
Copy link
Contributor Author

IgnacioPinedo commented Dec 14, 2022

All that would be needed is just update the tsconfig.json file to have the compilerOptions.module option set to CommonJS.

@HenryLuoOne
Copy link

I have same issue as well (version 2 is working, but not version 3), seeing same runtime error.

@cherath
Copy link

cherath commented Jun 15, 2023

I have the same issue. I have to move to v3.0.0.0 and now getting the same error. How did you resolve it?
The pull request has not been merged.

@knowvishnu
Copy link

Hi @IgnacioPinedo @HenryLuoOne @cherath, have you found any solution of this issue ?

@IgnacioPinedo
Copy link
Contributor Author

Just as a note, we still have not resolved this. Currently I have all my functions using AWS v3 expect credstash which is still using v2 due to this issue.

@IgnacioPinedo
Copy link
Contributor Author

Just waiting until it's released and I'll close the issue. The action to release is failing due to a token issue.

@cherath
Copy link

cherath commented Oct 17, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants