simonmcallister0210 / cognito-srp-helper

A helper for SRP authentication in AWS Cognito
Apache License 2.0
12 stars 3 forks source link

Error importing package using ES import #8

Closed simonmcallister0210 closed 1 year ago

simonmcallister0210 commented 1 year ago

Testing out the new npm package v1.0.0 I found there was an issue importing the package using ES imports:

import CognitoSrpHelper from "cognito-srp-helper";

I receive the following error:

node:internal/errors:478
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/tmp/xuubar/node_modules/cognito-srp-helper/dist/esm/cognito-srp-helper' imported from /tmp/xuubar/node_modules/cognito-srp-helper/dist/esm/index.js
    at new NodeError (node:internal/errors:387:5)
    at finalizeResolution (node:internal/modules/esm/resolve:330:11)
    at moduleResolve (node:internal/modules/esm/resolve:907:10)
    at defaultResolve (node:internal/modules/esm/resolve:1115:11)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:837:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
    at link (node:internal/modules/esm/module_job:75:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

This is likely because I'm not using .js file extensions on my imports. I'll need to update the ESLint config to enforce file extensions, then go through and update all the imports

NPM version: 8.19.2 Node version: 16.18.1