Can't find /bundle.js.map on the server Node.js

感情迁移 提交于 2021-01-05 07:33:04

问题


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


回答1:


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



回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/62204458/cant-find-bundle-js-map-on-the-server-node-js

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!