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

When Upgrade v5 to v6 Cannot find module './errors' #13771

Closed
zainiazhr14 opened this issue Dec 14, 2021 · 13 comments
Closed

When Upgrade v5 to v6 Cannot find module './errors' #13771

zainiazhr14 opened this issue Dec 14, 2021 · 13 comments
Assignees

Comments

@zainiazhr14
Copy link

I have issue when try upgrade v5 to v6 with error "Error: Cannot find module './errors'" and it show from "/node_modules/sequelize/lib/data-types"
Please Helpp
Thank You

@WikiRik
Copy link
Member

WikiRik commented Dec 14, 2021

To which version of v6 did you upgrade. v6.11.0?

@zainiazhr14
Copy link
Author

i use sequelize^6.12.0-beta.2(latest)

@WikiRik
Copy link
Member

WikiRik commented Dec 15, 2021

@zainiazhr14 I would recommend upgrading to v6.11.0 first since v6.12.0-beta2 is an experimental beta version.
Nevertheless, @allawesome497 can you check this issue out?

@zainiazhr14
Copy link
Author

okey thank you very much i hope can solve this problem

@Keimeno
Copy link
Member

Keimeno commented Dec 15, 2021

Could be due to #13710 will have to check it out. What node version are you using?

@zainiazhr14
Copy link
Author

node v14.18.2

@wbourne0
Copy link
Member

On node v14.18.2 I'm able to require sequelize@6.12.0-beta.2.

Can you make an example of this? Are you using import or require?

Also worth noting: If you have any imports directly to sequelize/lib that won't be supported anymore since that is the source of sequelize which is in the process of being converted to TypeScript.

The transpiled code should live in sequelize/dist/lib/* but I wouldn't recommend importing from there either; the sequelize index file exports everything from data-types.

@ephys
Copy link
Member

ephys commented Jan 6, 2022

This should have been resolved by #13795 which aliased /lib to /dist/lib. You still should not import anything from /lib yourself though.

Can you confirm that this is resolved @zainiazhr14?

@ephys ephys added status: awaiting response For issues and PRs. OP must respond (or change something, if it is a PR). Maintainers have no action and removed status: awaiting investigation labels Jan 6, 2022
@github-actions github-actions bot removed the status: awaiting response For issues and PRs. OP must respond (or change something, if it is a PR). Maintainers have no action label Jan 6, 2022
@sezanzeb
Copy link

sezanzeb commented Jan 15, 2022

I'm having this issue with v6.13.0

Locally it works though, running node v14.17.6

In a docker container running an image based on node:12.16.1-buster it fails with this error:

Error: Cannot find module './errors'
Require stack:
- .../node_modules/sequelize/lib/data-types.js
- .../node_modules/sequelize/lib/utils.js
- .../node_modules/sequelize/lib/model.js

@sezanzeb
Copy link

sezanzeb commented Jan 15, 2022

Can reproduce locally via nvm install 12.16.1 and running my tests with this version.

It works in 12.22.9

@ephys
Copy link
Member

ephys commented Jan 15, 2022

That's because at the beginning of the typescript migration, files were moved from /lib to /lib/dist
It wasn't considered a breaking change at the time because files in /lib were considered internal. They still are but we've decided to freeze v6 and continue these changes in v7 to avoid further non-semver-major breaking changes.

We've since added a workaround using node's exports field, but it requires node >=12.20.0

You should however avoid importing anything from /lib

@hasan-hashtagged
Copy link

The issues are still there. I cloned the repo and tried running tests against mysql db. The test file test/integration/data-type.test.js still uses require('sequelize/lib/data-types'). Is the migration still in progress? Also, in the package.json file, the entry points still contain lib.

@ephys
Copy link
Member

ephys commented Feb 21, 2022

If you cloned the sequelize repo, you need to run yarn build before running tests
/lib still exists, it's the build output of /src (#14068)

It's normal for the entrypoint to be in /lib as we need to expose the JS version of the codebase, not the TS one.

What this thread is about is that users should not try to import anything from /lib themselves directly. It's internal and prone to changes with no semver major bump.
i.e. don't do import DataTypes from 'sequelize/lib/data-types', do import { DataTypes } from 'sequelize'

It's normal for internal sequelize code to do it however

I'll close this issue as we've installed mitigation to not break v6 users that import from /lib, but we will remove this ability in v7 (exposing stable APIs instead)

@ephys ephys closed this as completed Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants