anikethsaha / mern

:tada: This is boilerplate for MERN stack with integrations like Redux and SSR :tada:
https://mern.netlify.com
MIT License
98 stars 44 forks source link

Fix server scripts runtime error due to mixed import and require usage #105

Closed ypahalajani closed 4 years ago

ypahalajani commented 4 years ago

The error arose when you run npm run watch which produces a fresh bin/server.js chunk containing mixed import and require syntax and then, run npm run server:dev which runs the server.js produced from last command.

Refer this.

PS: I edited the build to watch in the above statement.

anikethsaha commented 4 years ago

error arose when you run npm run build

you meant the webpack or watch command ?

ypahalajani commented 4 years ago

error arose when you run npm run build

you meant the webpack or watch command ?

Oh yeah! i forgot, you updated the build to watch. And, yes, I meant the watch command

anikethsaha commented 4 years ago

Okay, let me look into it.

As far as this is concerned this should not happen as those are webpack output files. Webpack should not output files having import statements in them ! thats what babel-loader is there for I don't know why it's happening. Maybe because of the target: node in the server config.

anikethsaha commented 4 years ago

Still dont know why its coming but merging this as this is a valid fix for this issue