jeanverster / chakra-ui-steps

Steps component designed to work seamlessly with Chakra UI
https://chakra-ui-steps.vercel.app
390 stars 44 forks source link

v2.1.0 causes "Cannot find module" error #134

Open wub opened 1 year ago

wub commented 1 year ago

After updating from 2.0.4 to 2.1.0, I now get this error (using this with Remix - so the code is running on both server and client).

[server] Error: Cannot find module '/Users/x/x/client/node_modules/chakra-ui-steps/dist/chakra-ui-steps.umd.cjs'
[server]     at createEsmNotFoundErr (node:internal/modules/cjs/loader:1112:15)
[server]     at finalizeEsmResolution (node:internal/modules/cjs/loader:1105:15)
[server]     at resolveExports (node:internal/modules/cjs/loader:579:14)
[server]     at Function.Module._findPath (node:internal/modules/cjs/loader:648:31)
[server]     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1076:27)
[server]     at Function.Module._load (node:internal/modules/cjs/loader:934:27)
[server]     at Module.require (node:internal/modules/cjs/loader:1157:19)
[server]     at require (node:internal/modules/helpers:119:18)
[server]     at Object.<anonymous> (/Users/x/x/client/app/root.tsx:5:37)
[server]     at Module._compile (node:internal/modules/cjs/loader:1275:14)
[server] yarn run dev:server exited with code 1
[remix] The path "chakra-ui-steps" is imported in app/root.tsx but "chakra-ui-steps" was not found in your node_modules. Did you forget to install it?

I imagine it might have something to do with this change?

2.0.4:

  "main": "./dist/chakra-ui-steps.umd.js",
  "module": "./dist/chakra-ui-steps.es.js",
  "exports": {
    ".": {
      "import": "./dist/chakra-ui-steps.es.js",
      "require": "./dist/chakra-ui-steps.umd.js"
    }
  },

2.1.0:

  "main": "./dist/chakra-ui-steps.umd.cjs",
  "module": "./dist/chakra-ui-steps.mjs",
  "exports": {
    ".": {
      "import": "./dist/chakra-ui-steps.mjs",
      "require": "./dist/chakra-ui-steps.umd.cjs"
    }
  },
arslansajid commented 1 year ago

I was using the version 2.0.4 and after upgrading to 2.1.0 facing the same problem.

lukaszszmolke commented 1 year ago

I have the same issue. Since it was not solved since April i decided fork library. Package ESM entrypoint needs to be upgraded.

I changed in package.json from:

"exports": {
    ".": {
      "import": "./dist/chakra-ui-steps.mjs",
      "require": "./dist/chakra-ui-steps.umd.cjs"
    }
  }

to:

"exports": {
    ".": {
      "import": {
        "default": "./dist/chakra-ui-steps.mjs",
        "types": "./dist/index.d.ts"
      },
      "require": "./dist/chakra-ui-steps.umd.js"
    }
  }

Currently works as expected :)

Explanation here: https://stackoverflow.com/questions/72457791/typescript-packages-that-ship-with-mjs-and-d-ts-but-without-d-mts-how-to-i

alisamar commented 7 months ago

After upgrading to 2.1.0, I have the same problem with the Jest test.

https://github.com/jeanverster/chakra-ui-steps/issues/134#issuecomment-1725255696 this worked for me too.

FAIL src/component/index.spec.tsx ● Test suite failed to run

Cannot find module 'chakra-ui-steps' from 'src/theme/index.ts'

Require stack:
  src/theme/index.ts
  test/index.tsx
  src/component/index.spec.tsx