complete-node-bootcamp icon indicating copy to clipboard operation
complete-node-bootcamp copied to clipboard

Could not load content for http://127.0.0.1:8000/bundle.js.map

Open hazartilirot opened this issue 4 years ago • 3 comments

For no reason the server is trying to load the file from the root even though the file created by the parcel located in the same directory with bundle.js.

The message I get in a console: DevTools failed to load SourceMap: Could not load content for http://127.0.0.1:8000/bundle.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE

hazartilirot avatar Oct 31 '20 08:10 hazartilirot

Here's two lines from the package.json if you're interested in it

"scripts": {
    "watch:js": "parcel watch ./public/js/index.js --out-dir ./public/js --out-file bundle.js",
    "build:js": "parcel build ./public/js/index.js --out-dir ./public/js --out-file bundle.js" 
  },

hazartilirot avatar Oct 31 '20 08:10 hazartilirot

Well, once bundler.js has been compiled if we open it and scroll to the very bottom, there is a line:

//# sourceMappingURL=/bundle.js.map

We can manually type the correct path like

//# sourceMappingURL=/js/bundle.js.map

the error would disappear though the question is why the parcel makes the path this way....

hazartilirot avatar Oct 31 '20 09:10 hazartilirot

Finally, the solution is found! You should insert --public-url . it'll do the trick!

    "watch:js": "parcel watch ./public/js/index.js --out-dir ./public/js --out-file bundle.js --public-url .",
    "build:js": "parcel build ./public/js/index.js --out-dir ./public/js --out-file bundle.js --public-url ."

hazartilirot avatar Oct 31 '20 09:10 hazartilirot