-
Notifications
You must be signed in to change notification settings - Fork 82
Cannot resolve module 'json' #17
Comments
Webpack:
|
@es6Test specifying the loader as 'json' (without the '-loader') worked for me.
|
thanks but still no luck:
|
{
"name": "__Demo__",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack --watch --watch-polling"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.4.5",
"babel-loader": "^6.2.1",
"babel-preset-es2015": "^6.3.13",
"css-loader": "^0.23.1",
"json-loader": "^0.5.4",
"style-loader": "^0.13.0",
"stylus-loader": "^1.5.1",
"webpack": "^1.12.12"
}
} |
I'm experiencing the same problem, path is definitely correct |
I solved the problem by adding an {test: /\.json$/, loader: "json", include: "path/to/your/sources"} |
weirdly... I was just having this issue and after running an npm install --save again it started resolving shrug |
Had the same problem but then recognized that the json-loader was not installed (and not in package.json). Shouldn't webpack complain in this case? Seems like a bug in webpack. |
it worked when i use the "var Page = require('json!./json/foo.json');",but not worked in "webpack.config.js" |
Same issue. Fixed by adding |
I think the most case of this issue is just because |
I could solve similiar error(not in mock) with npm install json-loader --save. I didn't install it. |
I've got the same problem - json load directly works, by webpack does not. works: import config from "!json!../../cfg/config.json" (I need to have !json! istead of json!) versions: |
I have absolutely installed all packages,but I also met this problem.When I do 'npm install json-loader --save' like JWplanet above ,it worked.I hoped that it would help you. |
In webpack: In main.js: in mains.js example: |
My solution:
|
Thanks @oleg-am |
Any update on this issue ? |
@vieillecam I'm not 💯 on this but if you're on webpack v2 I think I need to wait for reply on the webpack slack regarding this, in case it shouldn't be solved 😛 |
Thanks for you reply, it's already what I tried also without success. I'm not loading the loader explicitly and still receive special characters before the json loaded by webpack, as it was loaded already by something that put theses strange characters. |
I've seen this issue before with a json file having the diammond ? character. Some text editors could pick it up and some didn't. From memory sublime text did but atom didn't. Either try open the json in a different text editor and you should see it or copy the contents into a notepad and save that as the json. |
unsubscribing from my own thread, doesn't bother me anymore with WP2 |
@es6Test 👍 |
@vieillecam See @pizdetss comment and if you still got regressions either open a new issue and a test repo for reproduction would be appreciated also 😛 , e.g does it happen with every JSON file or with specific ones generated somewhere etc... |
@pizdetss Thanks for you comment, that was exactly my problem, I was doing my Json file only with Visual Studio Code and Sublime text and both of them were adding these extra ranges characters... Editing it with notepad++ resolve the issue. Thanks ! |
"Module not found: Error: Can't resolve 'foo.json" const webpack = require("webpack"); module.exports = { resolve: { modules: [ plugins: [ output: {
] AWS.JSX |
I got the same problem. "json-loader": "^0.5.4",
solved by adding './' before filename as per below
|
I'd suggest you play a little bit with the paths like ./../../temp/sample.json for example, depending where your request comes from it doesn't resolve ./ as a root. |
Hi, I am trying this, I am confident my paths are correct
var Page = require('json!./json/foo.json');
and get this error
The text was updated successfully, but these errors were encountered: