Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install from a git repo leaves a pretty blank package?

I am using working from this github issue and it says to use a temporary github fork until a pull request is merged in another repo....cool.

I try to add the github fork to my project dependencies by doing this...

    "reactstrap": "git+https://github.com/jameswomack/reactstrap.git",

in the package.json file and when I do a npm install everything goes according to plan, but then I get failures with my project not being able to find reactstrap...

When I go to inspect my node_modules I can see that the reactrap directory is pretty empty with only the LICENSE, README and package.json files...

What am I missing here?

like image 882
Joff Avatar asked Oct 07 '17 11:10

Joff


People also ask

Why npm install is not working?

If your npm is broken: On Mac or Linux, reinstall npm. Windows: If you're on Windows and you have a broken installation, the easiest thing to do is to reinstall node from the official installer (see this note about installing the latest stable version).

Can npm install from GitHub?

The npm installation from GitHub is quite useful for testing packages. It also gives the flexibility to install any specific branch, version, tag, and so on.

How do I prevent npm install from removing packages?

To Save : npm install --save {package_name} . This will save the package to package. json and install using npm install . You can't particularly control the dependencies(fully).


1 Answers

The package.json file of the repository contains these lines:

"files": [
    "LICENSE",
    "README.md",
    "CHANGELOG.md",
    "lib",
    "dist"
]

This is the list of files and directories to include in the npm package. As you can see, the actual JavaScript files will be located in the lib and dist directories.

The problem is that these directories are not checked into the Git repository, but created by a build, when you run npm run build.

A workaround that I would try: run the build, commit and push the generated files to your fork on GitHub. After that, installing the dependency the way you do it should give you the desired result.

However, if your goal is simply to test if your changes on a local fork of reactstrap work by including it as a dependency of a demo project, there is a better way: use npm link.

It works like this:

  • in the root of your local clone of your reactstrap fork, execute the command npm link
  • in the root of your demo project that uses reactstrap as dependency, execute the command npm link reactstrap

Any changes you then do to your reactstrap fork will be available in your demo project immediately.

like image 172
Patrick Hund Avatar answered Nov 15 '22 17:11

Patrick Hund