4

What is the proper syntax to add local project dependency in npm package.json file?

I have git project locally in C:\projects\MyApp

I want to get this project with npm install. I tried following

"dependencies": {
  .....
  "my-app": "file://../projects/MyApp/MyApp.git"
  .....
 }

but getting error

Could not install ....

Any suggestion?

αƞjiβ
  • 3,056
  • 14
  • 58
  • 95

3 Answers3

7

Finally got it working

"my-app": "../projects/MyApp"

Its' simple until you know.

αƞjiβ
  • 3,056
  • 14
  • 58
  • 95
1

Local dependency has to be a directory on your filesystem.


Alternately there is npm-link.

Excerpt from the docs:

Package linking is a two-step process.

First, npm link in a package folder will create a globally-installed symbolic link from prefix/package-name to the current folder (see npm-config for the value of prefix).

Next, in some other location, npm link package-name will create a symlink from the local node_modules folder to the global symlink.

Example:

cd ~/projects/node-redis    # go into the package directory
npm link                    # creates global link
cd ~/projects/node-bloggy   # go into some other package directory.
npm link redis              # link-install the package
0

File is the wrong protocol. You can use git+ssh or git+https. Here can you find more information about your question: https://stackoverflow.com/a/10391718/5111420

and I see a typo: dependencioes -> dependencies

Community
  • 1
  • 1
Silerra
  • 188
  • 2
  • 9
  • ahh, I have your question misunderstood, because I did not have the one sentence in focus: "I have git project locally in C:\projects\MyApp" – Silerra Nov 20 '15 at 00:00