question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: [universal-webpack] Your server source file must export a function

See original GitHub issue

I try to start the server build server like following:

nodemon -L ./start-server.js --exec babel-node --watch ./build/server

The server.js (built with webpack located in ./build/server/server.js) have a special webpack exported format and start-server.js and universal-webpack/server.js run in a normal node environment and tries to include the buit server.js here

https://github.com/halt-hammerzeit/universal-webpack/blob/master/source/server.js#L41

The result is that the “starter” variable become following:

[ 0, 1 ]

What did I miss?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
aight8commented, Jul 9, 2016

The comparison is not correct, it don’t remove any plugins now. It must check if the constructor.

return plugin!== _webpack2.default.HotModuleReplacementPlugin && plugin!== _webpack2.default.optimize.CommonsChunkPlugin;

should be:

return plugin.constructor !== _webpack2.default.HotModuleReplacementPlugin && plugin.constructor !== _webpack2.default.optimize.CommonsChunkPlugin;

Maybe a instanceof check do the job as well.

0reactions
catamphetaminecommented, Jul 9, 2016

Oops, really.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: [universal-webpack] Your server source file must export ...
it throw this error this is my webpack config: `import path from 'path'; import webpack from 'webpack'; import WebpackNotifierPlugin from ...
Read more >
universal-webpack - npm
Start using universal-webpack in your project by running `npm i ... source/server.js", ... The server code must export a function.
Read more >
Next.js 5: Universal Webpack, CSS Imports, Plugins and Zones
Errors that happen when server rendering now point to the correct function and line number. Errors now show the correct line, file and...
Read more >
What is the syntax to export a function from a module in Node.js?
In Node you export things with module.exports special object. For example: This exports both functions: module.exports = { foo, bar };.
Read more >
Importing and Exporting—Wolfram Language Documentation
m, and the converter sources reside in the files Converter.m. Format Registration. An Export format must first be registered. Note that, unlike registering...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found