-
-
Notifications
You must be signed in to change notification settings - Fork 526
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
Cannot find module '../package.json' when using webpack #2799
Comments
Thanks for the repro. I kinda hate webpack for this, but what can we do. Note that just changing it back to I guess I will revert back to the I don't understand how edit: I see, the file is there, so the check says let's require, but its not in the webpack bundle. But this one sounds like something you will need to get around by reconfiguring webpack. I can offer moving the |
Thanks for the reply! So I was actually changing the code in node_modules not the bundle, and then rebuilding which seemed to do the trick. Moving Also, I agree that webpack is a bit annoying. |
FYI I ended up doing both, moving the |
Describe the bug
When building with webpack, the function
Utils.getORMVersion
throws an error as it is unable to import package.json. This used to work in 4.x whenrequire('../package.json')
was used instead ofUtils.requireFrom
. The bug occurs in 5.0.0, 5.0.1 and 5.0.2. The code runs fine when using ts-node.Also another issue is with
ConfigurationLoader.getPackageConfig
which has the same problem as it recursively looks for package.json files and cannot import them. When deploying with webpack this won't be an issue as there would be no local package.json file but is an issue for those using webpack in development.Stack trace
To Reproduce
Repo - https://github.com/sayav/mikro-orm-webpack-issue
yarn start
runs using ts-nodeyarn webpack
creates bundle.js (when running with webpack, it's a good idea to copy bundle.js to a different location with no package.json files to avoid the second bug). Replacingreturn this.requireFrom('../package.json', __dirname).version
withrequire('../package.json')
inUtils.getORMVersion
solves the issue.Expected behavior
No crash
Versions
The text was updated successfully, but these errors were encountered: