question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dependency of json loader not installed by default though json loading is supported

See original GitHub issue

Can you reproduce the problem with latest npm?

Yes

Description

json file loading is supported as per react scripts but dependency on package json is not installed by default.

Expected behavior

import defaultData from './mealsdata.json';

should work by default

Actual behavior

Error:

Module not found: 'json' in /home/srinathh/src/bitbucket.org/srinathh/

however, it works after i do npm install --save-dev json

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
srinathhcommented, Mar 13, 2017

Hmmm… this was on an existing app. Let me try on a clean install of CRA, check and get back.

On Mar 13, 2017 23:29, “Dan Abramov” notifications@github.com wrote:

Hmm, json-loader does not depend on a module called json. Check its source code https://github.com/webpack-contrib/json-loader/blob/master/index.js and package.json https://github.com/webpack-contrib/json-loader/blob/master/package.json.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/facebookincubator/create-react-app/issues/1803#issuecomment-286190975, or mute the thread https://github.com/notifications/unsubscribe-auth/AC1hFVlVGU8_R2MOWCuoYRmBDxMeQ8y0ks5rlYPvgaJpZM4Mai77 .

0reactions
iamelicommented, Mar 26, 2017

I believe I have a consistent repro of this here. https://github.com/facebookincubator/create-react-app/issues/1895

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when attempting to import JSON into a React component
Error when attempting to import JSON into a React component: "You may need an appropriate loader", but the correct loader is already installed....
Read more >
json-loader - webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >
json — JSON encoder and decoder — Python 3.11.1 ...
The json module always produces str objects, not bytes objects. Therefore, fp.write() must support str input. If ensure_ascii is true (the default), the ......
Read more >
How to import JSON files in ES modules (Node.js) - Stefan Judis
This post explains ways to deal with JSON in ES modules if you don't want to use the experimental feature yet. Option 1:...
Read more >
ECMAScript modules | Node.js v19.3.0 Documentation
Modules are loaded multiple times if the import specifier used to resolve them has ... foo.json' assert { type: 'json' }; const {...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found