netlify-express icon indicating copy to clipboard operation
netlify-express copied to clipboard

WARNING in ./node_modules/express/lib/view.js

Open balibou opened this issue 6 years ago • 22 comments

When yarn build:

WARNING in ./node_modules/express/lib/view.js
81:13-25 Critical dependency: the request of a dependency is an expression
 @ ./node_modules/express/lib/view.js
 @ ./node_modules/express/lib/application.js
 @ ./node_modules/express/lib/express.js
 @ ./node_modules/express/index.js
 @ ./express/server.js

balibou avatar Jan 15 '19 00:01 balibou

any update on this issue. I get the same when I do yarn build?

dturton avatar Feb 14 '19 19:02 dturton

Hey guys would be great to get some help on this - I am not sure how to solve this in the netlify functions context...

https://github.com/webpack/webpack/issues/196

ydennisy avatar Mar 27 '19 09:03 ydennisy

I also see it using npm run build, and when I deploy a new site with it: https://app.netlify.com/sites/wonderful-golick-53c4d8/deploys/5ca55c306e2fd5fa0e0ff10d

However, the new site loads, so things appear to be working.

Is this blocking anyone from deploying successfully? If so, I am interested in how your site is set up.

neverendingqs avatar Apr 04 '19 01:04 neverendingqs

I found the same issue.

mikeyzhe avatar Apr 05 '19 18:04 mikeyzhe

WARNING in ./node_modules/express/lib/view.js 81:13-25 Critical dependency: the request of a dependency is an expression @ ./node_modules/express/lib/application.js @ ./node_modules/express/lib/express.js @ ./node_modules/express/index.js @ ./src/main/index.js @ multi ./node_modules/electron-webpack/out/electron-main-hmr/main-hmr ./src/main/index.js

same issue

beinimaliesi avatar Jul 04 '19 08:07 beinimaliesi

Also having this issue

virgilCane avatar Jul 08 '19 14:07 virgilCane

Use webpack-node-externals, I mean please add following code in your webpack.config.js

const nodeExternals = require('webpack-node-externals');

{ target: 'node', externals: [nodeExternals()], }

ajay-whiz avatar Jul 10 '19 07:07 ajay-whiz

Use webpack-node-externals, I mean please add following code in your webpack.config.js

const nodeExternals = require('webpack-node-externals');

{ target: 'node', externals: [nodeExternals()], }

maybe you can provide an example!!? Screenshot 2019-11-08 at 03 41 36 This is not helping

heshamelmasry77 avatar Nov 08 '19 00:11 heshamelmasry77

you need to first install webpack-node-externals dependency

npm install webpack-node-externals

or

yarn add webpack-node-externals

and then add whatever @heshamelmasry77 has suggested in the webpack.config.js

csmper avatar Nov 11 '19 15:11 csmper

Use webpack-node-externals, I mean please add following code in your webpack.config.js

const nodeExternals = require('webpack-node-externals');

{ target: 'node', externals: [nodeExternals()], }

Thanks, This solution solved my problem

hamidone avatar Dec 03 '19 12:12 hamidone

where is the webpack.config.js located?

neerujjain avatar Dec 21 '19 07:12 neerujjain

It's your file. You create it in order to customize webpack. I suggest you check out the webpack tutorial here.

aaronleesmith avatar Dec 27 '19 14:12 aaronleesmith

Use webpack-node-externals, I mean please add following code in your webpack.config.js

const nodeExternals = require('webpack-node-externals');

{ target: 'node', externals: [nodeExternals()], }

Doesn't this prevent the dependent node modules being bundled, and therefore they'll need to be added another way into the dist? If so, how should that be done?

joshgreifer avatar Jan 24 '20 15:01 joshgreifer

Still the same :/ Zrzut ekranu 2020-03-18 o 14 33 56

pz1996r avatar Mar 18 '20 13:03 pz1996r

You can add "express" to the externals object in webpack.config.js.

module.exports = {
  ...
  output: { ... },
  externals: {
    express: "require(\"express\")"
  },
  ...
}

This will prevent webpack from bundling express. Any other server-side specific libraries can be added to the externals object in order to prevent them from being unnecessarily bundled.

Externals is also used when creating npm packages. When creating a React component library for instance you can assume that the person consuming your package has React installed as a dependency so you don't want to add it to the bundle at compilation time, so you add it to the externals object. Your package will use the React library in the /node_modules/ of the project it is being consumed in.

If you don't want to use webpack-node-externals, I suppose this method gives you a lot more control over your webpack configuration.

@joshgreifer webpack-node-externals has an options.whitelist for your client-side dependencies.

ghost avatar Jun 19 '20 10:06 ghost

What if I want express to be bundled along with my node app?

frague avatar Nov 23 '20 20:11 frague

I don't understand why this happens. Tried both solutions, none worked, had to stash changes and git pull again... In my case it was during development bundling of a React app using Chakra UI (nothing to do with Netlify)

andrei-ce avatar Feb 09 '21 19:02 andrei-ce

Following ... I Got the same issue installing "express": "^4.17.1",

Tinbit avatar Feb 13 '21 12:02 Tinbit

Following ... I Got the same issue installing "express": "^4.17.1",

Same Here. Not sure why this is still an issue

DBCOOPER90 avatar Apr 07 '21 20:04 DBCOOPER90

Same issue here rip

ghost avatar Aug 27 '21 12:08 ghost

I don't understand, why the code is provided as non working and yet the demo works?

UPDATE

Everyone, make these changes and the problem is going away:
https://github.com/neverendingqs/netlify-express/pull/5/files

UPDATE2: the /dist directory is absent. Create it and place the index inside of it.

sscarduzio avatar Oct 08 '21 10:10 sscarduzio

Kindly check if you have any unwanted imports in your component

Hariharanu avatar Apr 22 '22 05:04 Hariharanu