-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
unclear how to resolve critical dependencies warning for express/lib/view.js #1576
Comments
Don't bundle |
@sokra |
@cch5ng I also am seeing this issue, did you ever solve it? I'm targeting node so not sure why I'm getting a warning. I'm using Express 4.13.3. |
@darrencrossley, sorry, I don't really have a deep understanding of webpack. since I reported this issue, I have been referencing bebraw's book (http://survivejs.com/webpack_react/webpack_and_react/) for basic webpack config (for react, babel). I have not experienced the same issue since but I also have not needed to install express individually. at the time I reported this, I was also new to using require or import and so there may have been user error involved. |
There's a dynamical requirement in UPD: As I find out webpack output |
Time to close. If still relevant, please re-open at Stack Overflow. |
Hi there... for those who get here.. use this module that it fixes all the warning for dependencies in your express app with webpac https://github.com/liady/webpack-node-externals |
This little "hack" works for me:
Basically it "skips" parsing "expressjs". |
@psulek this accomplished the same thing, basically telling webpack not to include express in the generated bundle.
|
@stephencranedesign yes you're right, that does not help, just tested it right now. |
@psulek - found this module and it did the trick for me: https://github.com/liady/webpack-node-externals |
https://github.com/liady/webpack-node-externals not only fixed my warnings / errors. It also reduced my file size tremendously from 2mb+ to 10kb. |
You should be aware that using |
What if you need to bundle your node modules? E.g., when creating an AWS lambda, your dependencies that you excluded aren't available on AWS environment, and will thus fail. Is there a way to resolve this warning without telling webpack to not include |
For times where I want to bundle everything together for use on the server, the best I could do was suppress the warning by adding the following to my webpack config:
|
Even shorter:
|
So far I see two approaches:
Not bundling externals removes much of the motivation to bundle the express server in first place. If there is little to gain from bundling, that would be ok. The potential I see for bundling the server would be a small gain in startup time and a smaller memory footprint. Am I missing something or would this be a negligible advantage? About ignoring the warning: So webpack warns that it can't determine what is actually being imported in view.js. What are the consequences? Would that dynamic import fail? If not, is there a risk that the import somehow interferes with bundled code? Would it simply result in potentially duplicated code? Or short: is it really safe to ignore the warning? I read somewhere else that such warnings have to be resolved via resolve aliases or otherwise. Is that impossible for this specific occurrence? |
Keep returning to this page for the error. Here is what helped me: ...
externals: [
{ express: 'commonjs express' },
nodeExternals({
whitelist: isDevelopment ? ['webpack/hot/poll?1000'] : [],
})
]
... |
improvement for bundle any node modules:
|
Improvement for in case you have multiple files to block errors from:
I have the same issue when I bundle mongodb. |
Installing @types/express fixed this for me. npm install --save-dev @types/express |
thanks this one work for me |
webpack 5 changes configuration for ignoring warnings little bit, this one works for me for disabling express view warning for webpack 5
|
Hi..thanks for this. In what file should I paste this as I am having the same issue |
In the webpack config file |
View.js hopefully is just template engine code It would make sense as it would be dymically importing an engine package. I'm guessing as long as you are not using However, depending on how webpack does things, if the rending library is included already in main project, then perhaps ^ if you're using express template render functionality, can you please ping below if it works in a one file webpack build? Linking issue with express repo incase someone there knows |
This then complains on the production server - " cannot find module 'express' ". |
Add plugin "webpack-node-externals" to your webpack.config.ts file, usage -> https://www.npmjs.com/package/webpack-node-externals |
hi, when I run webpack, I get a warning message like:
WARNING in node_modules/express/lib/view.js
Critical dependencies:
78:29-56 the request of a dependency is an expression
@ node_modules/express/lib/view.js 78:29-56
I'm not clear what I should do to resolve this. thanks.
The text was updated successfully, but these errors were encountered: