Closed centerorbit closed 4 years ago
https://github.com/webpack-contrib/node-loader#getting-started
You should set:
node: {
__dirname: false,
},
webpack@5 fix this issue out of box
Ahhhh, so that's what that config is for! Thank you! Tested and it works perfectly!
This issue is from trying to use the fix from #12 by @evilebottnawi
Expected Behavior
The node module is loaded via a relative path of './70a2ef50a7ff1fb36ab9b66e37a5f600.node' (or whatever other hash webpack decides to call the .node module)
Actual Behavior
An uncaught exception is thrown on the loading of the module:
Code
Webpack config:
How Do We Reproduce?
Here is a repo to repro: https://github.com/centerorbit/node-loader-path-bug
All built files are committed, so you can run:
npm run test
. To run webpack again, runnpm run build:js
.The '//' in front of '70a2...node' is telling. It's a result of this line: https://github.com/webpack-contrib/node-loader/blob/afc43f80046402774037a8c0de5e513f2795ffa1/src/index.js#L32
If you replace
__dirname + "/" + __webpack_public_path__
with./
the resulting webpack build works. I'm not versed enough in this modules intentions (or webpack in general) to know if this is the way to fix the problem, or if it's more a 'hack' (I suspect the later).