49

My project was working fine. When I upgraded to Webpack 5 this issue occurred. I searched online, but all the discussions seem to be from a previous version and I even tried the workarounds specified, but to no avail.

\SourceCode\node_modules\webpack\node_modules\webpack-sources\lib\SizeOnlySource.js:26
                throw this._error();
                ^
Error: Content and Map of this Source is not available (only size() is supported)
desertnaut
  • 57,590
  • 26
  • 140
  • 166
Abhilash K
  • 570
  • 1
  • 4
  • 7

11 Answers11

111

Sometimes, such errors occur as a result of incorrect assembly. Most likely angular using a webpack just made changes with an error. Try to delete the .angular folder, then run the

npm install

command and run the project with the usual command:

ng serve --open

If there is an error, try clearing the cache, or running your IDE as administrator.

Igor Vasiliev
  • 1,226
  • 1
  • 6
  • 6
31

If you're using angular, remove .angular folder from your project directory. Then rerun your app. It helped in my case.

Michał Stochmal
  • 5,895
  • 4
  • 36
  • 44
8

When I've disabled the sourceMap generation (for both local and prod configuration) the error no longer occured. Keep in mind this would work for some people, depends on the scenario. In my case I dont need sourceMaps even on local env:

enter image description here

I believe this problem is related somehow to Angular (as I have Angular project), and this might be something that they should address, instead of making changes on our angular.json file config.

Zdravko Kolev
  • 1,569
  • 14
  • 20
7

I have encountered the same issue today and I was able to solve the problem by installing the 'source-map-support' npm package:

npm install source-map-support
desertnaut
  • 57,590
  • 26
  • 140
  • 166
Erfan
  • 437
  • 5
  • 9
1

I'm using Webpack module federation in angular for developing micro frontend architecture.

Usually lot of dependencies or version mismatch is going to happen. Ref: Error Screen

Just do:

npm install

Sometimes if you added a new node packages then there is chances of getting these type of errors. So that, to update the packages which are most likely to be dependent on the new installed packages run - npm install.

It worked for me.

Again i faced same problem then i used the below command

npm install source-map-support

Also please check the port number which you are using for the project. Try to change the port numbers to a different port numbers which are unused and safer. Eg: If you are using the port http://localhost:2000/ then change it to different one in your angular.json file

"options": {
                        "port": 5000,
                        "publicHost": "http://localhost:5000",
                        "extraWebpackConfig": "projects/core/webpack.config.js"
                    }

and also if you customized the commands for each micro frontend apps then change the port numbers in package.json file also

    "ng": "ng",
    "start": "npm run start:core",
    "start:core": "ng serve core  -o --port 5000",
    "start:dashboard": "ng serve dashboard -o --port 3000"
    }
NeonH
  • 65
  • 2
  • 11
1

I have encountered the same issue and I was able to solve the problem by disabling cache by including in angular.json file

"cli": {
    "cache": {
      "enabled": false
    }
  }
0

If npm install then ng serve --open doesn't work for you : you need to remove node modules

rm -r .\node_modules\ 

then remove package-lock.json and finally reinstall node modules

npm install

now you can run ng serve and it will work

Omar Jribi
  • 89
  • 1
  • 3
0

I have faced the same issue with the angular devtool library:

node_modules/@angular-devkit/build-angular/node_modules/webpack/node_modules/webpack-sources/lib/SizeOnlySource.js:16

None of the previous solutions has worked for me, and after some checking and trying, it was a problem with one of the Chrome browser extensions, So I have been running it in Firefox and everything is fine, or by disabling the extension that cause the problem.

Anyone can check this thread for more details about Chrome.

Ebraheem Alrabeea
  • 2,130
  • 3
  • 23
  • 42
0

I tried all the above alternatives with failure. In my case, what worked was using a previous version of node to compile. The error happened with node > 14.18.0. Compilation works correctly here on v14.15.3 (angular 13)

0

Try

ng cache clean

Then

ng serve
  • 1
    Thank you for your interest in contributing to the Stack Overflow community. This question already has quite a few answers—including one that has been extensively validated by the community. Are you certain your approach hasn’t been given previously? **If so, it would be useful to explain how your approach is different, under what circumstances your approach might be preferred, and/or why you think the previous answers aren’t sufficient.** Can you kindly [edit] your answer to offer an explanation? – Jeremy Caney Aug 28 '23 at 00:05
-1

Installing the webpack sources did it for me:

npm i --save webpack-sources
Blank
  • 4,872
  • 2
  • 28
  • 25