1

I am following a tutorial , now i am getting this error when i try to update a user data , i have tried to re-install parcel package

npm install -g bundle-js

here is package.json:

enter image description here

here is directory:

enter image description here

since my bundle.js and bundle.js.map is under the /public/js , how can i route the directory enter image description here

AnotherOne
  • 78
  • 2
  • 11

3 Answers3

5

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....

P.S.>

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
  • 195
  • 1
  • 2
  • 11
0

From the official documentation you can run npm install -g parcel-bundler.

Inside of package.json add --out-dir .public/js like so:

"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"
  },

Edit: Restart both the Node.js server and the bundler for changes to work.

Andrey
  • 66
  • 4
0

package.json "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" },

I ran into the same issue. Here's the message I get in 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

Everything seems to be working, the file's location is in .public/js for no reason the server is looking for the file in the root.

hazartilirot
  • 195
  • 1
  • 2
  • 11