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

Add file extensions to imports to support node 12 #12

Open
n1474335 opened this issue Jul 9, 2019 · 1 comment · May be fixed by #13
Open

Add file extensions to imports to support node 12 #12

n1474335 opened this issue Jul 9, 2019 · 1 comment · May be fixed by #13

Comments

@n1474335
Copy link

n1474335 commented Jul 9, 2019

In Node 12, extensions are required on all import statements so that Node knows whether to treat it as a module (mjs) or a script (js).

Currently, running crypto-api in Node 12 gives the following error:

>> internal/modules/esm/default_resolve.js:59
>>   let url = moduleWrapResolve(specifier, parentURL);
>>             ^
>> 
>> Error: Cannot find module '/node_modules/crypto-api/src/hasher/has160' imported from /node_modules/crypto-api/src/crypto-api.mjs
>>     at Loader.resolve [as _resolve] (internal/modules/esm/default_resolve.js:59:13)
>>     at Loader.resolve (internal/modules/esm/loader.js:73:33)
>>     at Loader.getModuleJob (internal/modules/esm/loader.js:149:40)
>>     at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:43:40)
>>     at link (internal/modules/esm/module_job.js:42:36) {
>>   code: 'ERR_MODULE_NOT_FOUND'
>> }

Changing all your imports to specify the file extension will solve this.

@n1474335
Copy link
Author

This is currently causing some issues in CyberChef and preventing our API from working correctly (see gchq/CyberChef#600). Is there any way this could be fixed soon?

crypto-api is a really great library and I believe we use almost everything it provides so it would be a shame to have to move away from it.

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

Successfully merging a pull request may close this issue.

1 participant