node-source-map-support: Module not found: Error: Cannot resolve module 'module' in [...]source-map-support @ source-map-support.js 464:17-34
I am using source-map-support
0.4.5
in a module of mine (let’s call it moduleA
).
I then publish moduleA
to npm and all’s well till that point.
Then I try to use that moduleA
in another project of mine (let’s call it moduleUser
). After I do npm install
in moduleUser
I try to do an npm run build
which is configured in package.json
as:
$ grep \"build\"\: package.json
"build": "webpack --progress --colors",
… and I then encounter (at the end of the build process) the following message which I can’t decipher:
ERROR in …/~/moduleA/~/source-map-support/source-map-support.js Module not found: Error: Cannot resolve module ‘module’ in /home/carsten/moduleUser/node_modules/moduleA/node_modules/source-map-support @ …/~/moduleA/~/source-map-support/source-map-support.js 464:17-34
Looking in the identified location in file source-map-support.js
the line is:
var Module = require('module');
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 21
- Comments: 29
Commits related to this issue
- nailing source-map-support to 0.4.3 to circumvent problem described in https://github.com/evanw/node-source-map-support/issues/155 — committed to mperdikeas/js-geometry-2d by mperdikeas 8 years ago
- Fixed source-map-support.js throwing require errors by temporarily pinning to 0.4.3 - https://github.com/evanw/node-source-map-support/issues/155 — committed to jmfirth/typescript-playground by jmfirth 7 years ago
Seeing the same issue in 0.5.1, as well as unresolved ‘fs’ module. The following addition to the top level of my webpack.config.js fixes it:
I still see this issue in 0.4.11.
Nailing the
source-map-support
version to0.4.3
indeed fixes the problem.I am using Angular 5, Angular cli 1.5.2 and everything was fine until I added and used
import * as ts from "typescript";
My error starts with
And continues something like 1000 more lines… Not sure what I can do about it. Any idea? Here is my package.json.
I have this issue with
v0.4.18
. Downgraded tov0.4.3
and issue still exists. But I haveAnd I think babel-core uses 0.4.18 no matter of source-map-support installed package on top level. I didn’t have this issue long time, because in my React/Webpack codebase I didn’t have
require('module')
untill now. And I rather need it for some time, which later on, myabe, will be removed/moved/modified/deprecated.But the issue interesting. AMD vs. CJS.
Then I changed my webpack.config.js and added one more line:
And issue gone. Partially.
Such behavior is odd 😃 Just imagine, 2018 year, we work on NPM modules, module is essential for require/CJS and we have to add some explicit code to “see” it 😃
But it’s not the end. My webpack build process is OK, and warning is suppressed, but when I run my application, when the code tries to access to require(‘module’) I have error in console:
And here is my piece of code:
test.js
In fact my
console.log(module);
is an empty{}
object. and I know it should be object with properties (exports, config, etc).I manage code to provide
config
, but I though there is always by default some module.config() => {} at least. Not sure.ANyway, I changed my code to this:
And now webpack/react based app at least works with no errors. But still, it’s no ideal fix I assume.
I have a similar issue:
For anyone having the issue with the Next.js library, here is the workaround:
next.config.js
https://github.com/webpack-contrib/css-loader/issues/447#issuecomment-368345121
Still seeing in 0.5.0 😢 removing ‘^’ from package.json does not solve the issue
I don’t know what am doing wrong please someone help take a look at my config and how i tried to apply the workaround.
`var Encore = require(‘symfony/webpack-encore’);
Encore
/trying to add the work around here and i get error/
;
module.exports = Encore.getWebpackConfig();`
when i run
yarn run encore dev
i get error ` Error: Encore.node is not a recognized property or method.index.js:942 Object.get [chukolo]/[@symfony]/webpack-encore/index.js:942:27
webpack.config.js:44 Object.<anonymous> C:/xampp/htdocs/chukolo/webpack.config.js:44:5
module.js:652 Module._compile module.js:652:30
module.js:663 Object.Module._extensions…js module.js:663:10
module.js:565 Module.load module.js:565:32
module.js:505 tryModuleLoad module.js:505:12
module.js:497 Function.Module._load module.js:497:3
module.js:596 Module.require module.js:596:17
module.js:11 require internal/module.js:11:18
convert-argv.js:97 requireConfig [chukolo]/[webpack]/bin/convert-argv.js:97:18
error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this comm and. `
I still see this issue in 0.5.4.
attention