Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add dependency from another Github project?

In my new project created using the command:

npm init

I want do add dependency from another GitHub project, so I used command:

npm install https://github.com/cichy380/prefixData.git --save-dev

but I got error:

npm ERR! code ENOPACKAGEJSON

npm ERR! package.json Non-registry package missing package.json: git+https://github.com/cichy380/prefixData.git.

npm ERR! package.json npm can't find a package.json file in your current directory.

Can you explain me why?

like image 213
Cichy Avatar asked Aug 17 '18 14:08

Cichy


People also ask

How to add an existing project to GitHub?

To add your existing project to GitHub, follow the below steps, Create a Github account. Once logged in, click on the + icon on the extreme right corner and select New Repository Here you need to provide the name and description of your repository and also the permissions (Public/Private) which is self explanatory.

How do I view dependencies on GitHub repository?

On GitHub.com, navigate to the main page of the repository. Under your repository name, click Insights . In the left sidebar, click Dependency graph . Optionally, under "Dependency graph", click Dependents . Dependencies are grouped by ecosystem. You can expand a dependency to view its dependencies.

How do I add an existing Git repository to GitHub?

You can add an existing Git repository to GitHub using GitHub Desktop. Using the command line, remove any git remotes currently configured for the repository.

How do you manage your dependencies without Git?

First choice: Use an appropriate build/dependency tool instead of git A dependency management tool is my current recommended way forward to handle the growing pains and the build times of sizeable projects. Keep your modules separated in individual repositories and manage their interdependency using a tool built for the job.


1 Answers

I believe I can answer your question "Can you explain me why?"

Given the limited information in the question no one can for certain tell you the root cause of your error, but it COULD be one of these reasons:

  1. The simplest problem could be there is no package.json in your repository; OR
  2. In your question you say that you executed the command:

    npm install https://github.com/cichy380/prefixData.git --save-dev
    

    This is not a valid npm package git url format. It's possible that if you used the protocol git+https you will not get that error, like so

    npm install git+https://github.com/cichy380/prefixData.git --save-dev
    

    I'm not sure if that's valid across all npm versions, but as you will see in the npm package docs link it does not allow for just https protocol; OR

  3. Two reasons I can't say for certain 2 is your problem is ONE, not sure what version npm package you're using and what npm versions obey the docs I provided as a link and TWO your error you provided includes the git+https protocol so thats confusing:

    npm ERR! package.json Non-registry package missing package.json: 
    git+https://github.com/cichy380/prefixData.git.
    

Hopefully this helps someone!

like image 91
Developer_Gren Avatar answered Oct 20 '22 04:10

Developer_Gren