Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'source-map' #23649

Open
Legends opened this issue Feb 14, 2018 · 18 comments
Open

Cannot find module 'source-map' #23649

Legends opened this issue Feb 14, 2018 · 18 comments

Comments

@Legends
Copy link

@Legends Legends commented Feb 14, 2018

If you know how to fix the issue, make a pull request instead.

"dependencies": {
    "@types/html-webpack-plugin": "^2.30.2",
    "@types/node": "^9.4.5",
    "@types/webpack": "^3.8.7"
  },
  "devDependencies": {
    "@types/jquery": "^3.3.0",
    "@types/lodash": "^4.14.102",
    "html-webpack-plugin": "^2.30.1",
    "jquery": "^3.3.1",
    "lodash": "^4.17.5",
    "ts-loader": "^3.5.0",
    "typescript": "^2.7.1",
    "webpack": "^3.11.0"
  },

This happens after installing the following package:

npm install @types/webpack
or this package:
npm install @types/html-webpack-plugin

PS C:\inetpub\wwwroot\WebPack_TypeScript_Setup_Example> tsc

node_modules//index.d.ts(9,32): error TS2307: Cannot find module 'source-map'.
node_modules//index.d.ts(20,30): error TS2307: Cannot find module 'source-map'.

@j-oliveras told me to try this:
npm install @types/source-map@0.5.2

Now I don't get these errors anymore, but if I install the latest version of source-map the problem returns !

@GabrielDuarteM

This comment has been minimized.

Copy link

@GabrielDuarteM GabrielDuarteM commented Mar 3, 2018

Happened to me too, if I install the latest @types/source-map, i get the following errors:

ERROR in <PATH_TO_PROJECT>/node_modules/@types/uglify-js/index.d.ts(9,32):
TS2307: Cannot find module 'source-map'.
ERROR in <PATH_TO_PROJECT>/node_modules/@types/webpack/index.d.ts(20,30):
TS2307: Cannot find module 'source-map'.

if I install @types/source-map@0.5.2, the problem goes away.

@DjangoFR

This comment has been minimized.

Copy link
Contributor

@DjangoFR DjangoFR commented Mar 5, 2018

The same problem here! Thank you @GabrielDuarteM

@Legends

This comment has been minimized.

Copy link
Author

@Legends Legends commented Mar 10, 2018

Any updates on this ? @rbuckton , @jvilk , adding @tkrotoff

I get this error constantly when creating a new project:

node_modules/@types/uglify-js/index.d.ts(9,32): error TS2307: Cannot find module 'source-map'.
node_modules/@types/webpack/index.d.ts(23,30): error TS2307: Cannot find module 'source-map'.

@jvilk

This comment has been minimized.

Copy link
Contributor

@jvilk jvilk commented Mar 11, 2018

source-map ships with its own types from 0.5.7 on.

Here's what I think will work, but have not tested:

  • If your code depends directly on source-map version 0.5.7 or above (e.g. source-map is in your dependencies/devDependencies), then do not install @types/source-map; source-map ships with its own types.
  • If your code does not directly depend on source-map, then I believe you should be able to either install @types/source-map or source-map to resolve the problem, but don't install both.

Does that help at all?

@kalupa

This comment has been minimized.

Copy link

@kalupa kalupa commented Mar 12, 2018

I just tried to install source-map 0.5.7 and have the errors described. Perhaps it's a problem downstream with uglify and webpack types

@Legends

This comment has been minimized.

Copy link
Author

@Legends Legends commented Mar 14, 2018

Problem is fixed when installing: "source-map": "^0.7.2",

@Legends Legends closed this Mar 14, 2018
@GabrielDuarteM

This comment has been minimized.

Copy link

@GabrielDuarteM GabrielDuarteM commented Mar 14, 2018

@Legends the issue still remains for me when installing "source-map": "^0.7.2". If I install just @types/source-map@0.5.2 (just the typing, without the source-map package, as I don't use it anywhere) the problem goes away, but if I uninstall the types, the same error comes back.

@Legends

This comment has been minimized.

Copy link
Author

@Legends Legends commented Mar 14, 2018

Reopening the issue as @GabrielDuarteM still has problems...

@Legends Legends reopened this Mar 14, 2018
@RikkiGibson

This comment has been minimized.

Copy link

@RikkiGibson RikkiGibson commented Jun 6, 2018

Does it make sense to need to install the types for a module you don't directly depend on? Shouldn't @types/webpack just depend on it explicitly if it actually needs them?

@koichirokamoto

This comment has been minimized.

Copy link

@koichirokamoto koichirokamoto commented Jun 13, 2018

The issue have raise when install latest version 0.5.7 of @types/source-map. 0.5.2 is ok.

@zeronight

This comment has been minimized.

Copy link

@zeronight zeronight commented Sep 25, 2018

I fixed it like this:

  1. install source-map
npm install source-map --save-dev
  1. set moduleResolution to node in tsconfig.json
{
  "compilerOptions": {
    "moduleResolution": "node"
  }
}
@Legends

This comment has been minimized.

Copy link
Author

@Legends Legends commented Sep 26, 2018

@GabrielDuarteM Still an issue or can I close it?

@strongui

This comment has been minimized.

Copy link

@strongui strongui commented Nov 8, 2018

@Legends I'm still having the issue.

@JalilArfaoui

This comment has been minimized.

Copy link

@JalilArfaoui JalilArfaoui commented Jan 16, 2019

I'm having the same issue too.

yarn add --dev @types/source-map@0.5.2 fixes it like @GabrielDuarteM said

@retorquere

This comment has been minimized.

Copy link

@retorquere retorquere commented Jan 25, 2019

Same here -- npm install --save --dev @types/source-map@0.5.2 worked for me.

retorquere added a commit to retorquere/zotero-report-customizer that referenced this issue Jan 28, 2019
@mirismaili

This comment has been minimized.

Copy link

@mirismaili mirismaili commented Feb 8, 2019

Thank @zeronight.

tsc [...] --moduleResolution node

worked.

In my case, there was no need to neither source-map nor @types/source-map.

@lcpautotester

This comment has been minimized.

Copy link

@lcpautotester lcpautotester commented Jun 18, 2019

Same here -- npm install --save --dev @types/source-map@0.5.2 worked for me.

this fixed it for me , too. why isnt this fixed by now??

yjwong added a commit to glints-dev/hapi-webpack-dev-server-plugin that referenced this issue Nov 9, 2019
@juwaki

This comment has been minimized.

Copy link

@juwaki juwaki commented Feb 24, 2020

after upgrading to angular 9
image
i did npm install --save --only=dev @types/source-map@0.5.2

and the error didnt go away,

Solution
ended up removing --save --only=dev and did

npm install @types/source-map@0.5.2

which worked perfectly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.