Reputation: 101
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:
here is directory:
since my bundle.js and bundle.js.map is under the /public/js , how can i route the directory
Upvotes: 1
Views: 2649
Reputation: 355
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 ."
Upvotes: 5
Reputation: 355
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.
Upvotes: 0
Reputation: 66
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.
Upvotes: 0