1

I have 2 projects(packages) in npm, I want to inject package_A as dependency to package_B. In package_A root folder, I run npm install -g, then npm install it to C:\Users\Myuser\AppData\Roaming\npm\node_moduls\package_A folder. Now in packages.json in package_B I add "package_A": "1.0.0" in dependencies. When in package_B root file I run npm install, its failed package_A@1.0.0 not found.

How can I identified npm to its my own local package?

Notes:

  • We are a team, then I don't want to address package_A explicitly.
  • We are using nexus repository manager.
  • I don't want to publish my projects to http://registry.npmjs.org/.
Morteza Malvandi
  • 1,656
  • 7
  • 30
  • 73

1 Answers1

0

I'm not 100% clear what you have tried. If you are going to use a custom module for another application you are developing, installing globally won't do the trick. You have to publish that module in npm. Check this link for more info on publishing in npm

If you have completed the steps correctly, and still no good happens, please check your naming of the module in package.json file. Instead of typing in the name and version number in package.json file and then npm install, try directly installing in the terminal with --save so that it will automatically be added to package.json file with correct spelling.

  • I don't want to publish it to npm server. I only wants to publish it in my computer so that my another modules access it. – Morteza Malvandi Dec 30 '17 at 17:54
  • There's no such thing called 'publishing in your computer'. You only 'install' . in your computer; globally or locally in the project directory. If you have installed globally, why do you want to install it again using `npm install` anyways? (BTW, in case your concern is about that 'module going public', you can use a private account in npm. – Kavin Ranawella Dec 30 '17 at 18:32
  • Any modules must publish in npm server? If I don't want it, What should I do? – Morteza Malvandi Dec 31 '17 at 04:33
  • There can be other solutions, but I can think of only 'adding the required files in your project directory and importing them'. – Kavin Ranawella Dec 31 '17 at 12:41