Absolute node_modules paths are not getting resolved during SSR
See original GitHub issue💬 Questions and Help
I am not sure if this issue is similar to #293.
I am importing a component from node_modules.
const ComponentName = loadable(() => import("@nodeModuleName/[path-to-component]") );
This import runs on client side. (i.e., when I run using { ssr: false }, the component gets load). But it does not load on server side. Throws error
Cannot find module '/Users/[my-project]/@nodeModuleName/[path-to-component]'
the import gets resolved to
var ComponentName = (0, _component.default)({
chunkName: function chunkName() {
return "ComponentName";
},
isReady: function isReady(props) {
if (typeof __webpack_modules__ !== 'undefined') {
return !!__webpack_modules__[this.resolve(props)];
}
return false;
},
requireAsync: function requireAsync() {
return import(
"@nodeModuleName/[path-to-component]");
},
requireSync: function requireSync(props) {
var id = this.resolve(props);
if (typeof __webpack_require__ !== 'undefined') {
return __webpack_require__(id);
}
return eval('module.require')(id);
},
resolve: function resolve() {
if (require.resolveWeak) {
return require.resolveWeak("@nodeModuleName/[path-to-component]");
}
return require('path').resolve(__dirname, "@nodeModuleName/[path-to-component]");
}
});
Issue #293 mentioned that he is not using webpack but I do use webpack, then also getting error. Any help is appreciated
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
import is not working nodeJs application React SSR
We name it webpack.config.js in the root of the app. const path=require("path") module ...
Read more >Advanced Features: Absolute Imports and Module Path Aliases
Configure module path aliases that allow you to remap certain import paths. ... Note: jsconfig.json can be used when you don't use TypeScript....
Read more >Static Asset Handling - Vite
Importing a static asset will return the resolved public URL when it is served: ... be either using absolute public paths (based on...
Read more >Node.js path.resolve() Method - GeeksforGeeks
The path.resolve() method is used to resolve a sequence of path-segments to an absolute path. It works by processing the sequence of paths...
Read more >css-loader | webpack - JS.ORG
If set to false , css-loader will not parse any paths specified in url or ... To import assets from a node_modules path...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think the problem is here:
We should replace it by:
What do you think @theKashey?
@neoziro Thank you so much for such a prompt release!