Ash Ash - 1 year ago 135
React JSX Question

ESLint importing react

I'm using eslint and getting this error because of

on a bunch of stuff inc react, chai, react-dom etc

'react' should be listed in the project's dependencies. Run 'npm i -S react' to add it

In my package.json I have the following ('...' represents other packages that don't seem relevant):

"dependencies": {
"react": "^15.2.1",

I have a package.json in the root of my project but I also have individual package.json files for each of my components. Is there a way for it to reference the root file dependency or do I have to add it to all the individual component package.json files as well?

Answer Source

AFAIK, there isn't an option to reference a parent package.json (see also this issue), because npm assumes self-contained, independent packages.

So if you want to get it working properly, you'll have to list all dependencies for each component in their respective package.json file, basically making each component an independent package.

That, or work around the reason why you need separate package.json files for each component.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download