Cannot find module 'bcrypt-ts/node' or its corresponding type declarations.
I get issues when importing this module in our jest environment (`import { hashSync } from 'bcrypt-ts'`). So as suggested in the README I switched to `import { hashSync } from 'bcrypt-ts/node'` and while that fixes things to work correctly when running our tests we get errors in vscode that I cannot resolve:
`Cannot find module 'bcrypt-ts/node' or its corresponding type declarations.`
Any ideas?
This was a workaround in our repo (to get the tests to run when using `import { hashSync } from 'bcrypt-ts'`) but I'd prefer not to have to hardcode these things in jest config (we are using yarn workspaces in a monorepo):
```
moduleNameMapper: {
'bcrypt-ts': '<rootDir>/../../node_modules/bcrypt-ts/dist/node.cjs',
},
```
I guess the reason this works is because jest sees an `import` which you have mapped to an mjs file, not cjs file.
关闭于 2023-12-30 4 条评论