6

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?

2
  • there is a typo in the question above: 'dependencioes' Commented Jun 12, 2018 at 14:15
  • corrected the typo Commented Jun 13, 2018 at 18:05

3 Answers 3

10

Finally got it working

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

Its' simple until you know.

Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

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

1 Comment

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"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.