New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot read property 'replace' of undefined whit Invalid JSON #7082
Comments
Getting the same error. It barfs on the websocket module, which is a dependency of the SockJS client. |
Looks like a bug, feel free to send PR |
@evilebottnawi Okay, and what's the correct fix? Provide a default value so |
I encountered the same issue, but I'm trying to convert a webpack 3 project, where the json loads perfectly fine, and should be valid. What is really strange to me is that even this crashes webpack: |
Catch up with the same problem. I updated the webpack to 4.6, but the error was not lost. |
as @badpunman points out above, there seems to be no way to require() files with .json extension that are not valid JSON in webpack - even with raw-loader! or forcing the loader in config to be raw does not help, although it fails in a different place;
The only workaround I've discovered so far is using another extension than .json. This might be a separate issue, though? |
add |
Could this be due to the json file encoding? I have run into this same error due to my json being encoded with BOM. Changing to just utf-8 solved it for me. |
I imagine this is probably an issue. Would explain why my jsons wouldn't work in webpack 4. I can't confirm right now for sure though. I'm developing on windows so it could even be about line endings that crash it. The overly strict json file format support might be deserving of a separate open issue though, as this primarily deals in error handling. |
I'm hitting this too, and it really needs to be fixed! |
+1 |
Would love to see a fix too! :) When watching a file base and importing .json files based on require.context the webpack compiler breaks completely on every new .json file you create. With |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Webpack exit abruptly when a JSON is not formatted correctly when a server is running.
I'm using webpack 4.6.0, I run a local server using serve from 'browser-sync'
I DON'T use json-loader in webpack-config as it is my understanding that it handles it by default now.
I run a local server, do a change to a JSON file that makes the JSON invalid, at this point webpack exit abruptly with the following error:
If the current behavior is a bug, please provide the steps to reproduce.
Clone the repo: https://github.com/Tonio31/Webpack4-Bug-with-JSON.git
What is the expected behavior?
Webpack shows an error in the console because the JSON is not formatted correctly but don't exit, when the JSON is fixed, webpack automatically compile without errors
If this is a feature request, what is motivation or use case for changing the behavior?
Please mention other relevant information such as the browser version, Node.js version, webpack version, and Operating System.
Webpack: 4.6.0
browser-sync: 2.23.6
StackOverflow question:
Overview of webpack config:
The text was updated successfully, but these errors were encountered: