1

I installed a module with option of global. Late on I found no entry of the module in package.json. I know there will be an entry without global option. I verified that the module was properly responding in command line. How do I add a global module to the package.json for the project?

user938363
  • 9,990
  • 38
  • 137
  • 303
  • 2
    Install the module normally, `npm install `. Instead of using the globally-installed module, you can (and generally should) run the local instance using npm scripts or using the `npx` command. – benbotto Feb 11 '20 at 19:22
  • 1
    Does this answer your question? [Install dependencies globally and locally using package.json](https://stackoverflow.com/questions/6480549/install-dependencies-globally-and-locally-using-package-json) – benbotto Feb 11 '20 at 19:25
  • `avejidah`, I read the post before posting. The module I installed didn't work without global option (strange). That's why I was forced to use global.But I didn't find the module under node_modules. – user938363 Feb 11 '20 at 19:48
  • What's the module that you're installing globally? Also, when you say "didn't work," what specifically was the issue? – benbotto Feb 11 '20 at 19:50
  • The module is ipfs, installed with nodejs-mobile-react-native (provide nodejs for react native) on React Native 0.61.5. It is a little complicated. – user938363 Feb 11 '20 at 19:52
  • In a new folder I run the following: `npm init; npm install --save-dev ipfs@0.40.x; npx jsipfs` I see the help dialog printed in the terminal. Does `npx jsipfs` work for you? – benbotto Feb 11 '20 at 19:57
  • `npx jsipfs` did work and also `jsipfs`. The `ipfs` is installed under `nodejs-assets/nodejs-project` created by module `'nodejs-mobile-react-native`. `nodejs-mobile-react-native` provides `nodejs` environment on mobile platform. – user938363 Feb 11 '20 at 20:01
  • Seems like a question for the maintainers of the `ipfs` module then. To answer the question you asked here, installing a global module does not change your project's package.json. You can't add a global module to package.json, nor should you ever need to. A goal of package managers is to freeze the project's dependencies' versions, and using global dependencies is antithetical to that goal. – benbotto Feb 11 '20 at 20:07

0 Answers0