I would like to have redux-thunk
in my package.json
, but use the globally installed version (not in my project-specific node_modules
folder). Do I need to add it to my package.json
manually? Using npm install -g redux-thunk
doesn't add the package to my package.json
. Also, when I run my react app and import redux-thunk
, I get a module not found error
even though redux-thunk
is installed globally. Is this because I am required to have the package in my project's node_modules
folder and not in the global installation location?
Asked
Active
Viewed 346 times
0

J Bailey
- 13
- 3
-
Does this answer your question? [NodeJS require a global module/package](https://stackoverflow.com/questions/15636367/nodejs-require-a-global-module-package) – RobC Jun 03 '20 at 10:06
-
However, typically you wouldn't use a globally installed package in your local project. Instead you would install it in your local projects _node_modules_ directory. For example; **1)** `cd` to your project directory. **2)** Then run `npm install redux-thunk ` _(i.e. without the `-g` option)_ – RobC Jun 03 '20 at 10:10
-
That question was helpful but does that translate over to react? Also, would it be possible to install it globally _and_ add it to package.json (without installing in the specific project) – J Bailey Jun 04 '20 at 07:04
1 Answers
0
the -g
flag installs it globally. If you want to add it to your package.json
file go to the directory where your package.json
file is and run:
npm install redux-thunk

dcts
- 1,479
- 15
- 34
-
But if I do `npm install redux-thunk` then it will download and add the package in my `node_modules` folder, which isn't what I want because I want to use the global version. Is there a way to get the module in `package.json` and still only install the global module? – J Bailey Jun 03 '20 at 07:05