Install package.json dependency from git, not npm

I’m trying to install gitkit but it depends on a fork of dissolve, which is only on github, not on npm. https://github.com/SamyPesse/gitkit-js/issues/6

npm on HyperDev can’t install it becuase it doesn’t have a command line git installed. Can this be fixed?

This would also allow installing custom packages by adding things like:

	"node-wirc": "git://github.com/rjmunro/node-wirc#master"

to dependencies, which would be a really useful way to test and demonstrate changes you have made to the package before making a pull request to the original author.

1 Like

Thanks for the report! We’ll look into fixing it and will update this thread when it’s released.

I know this is a year old, but I thought I would put this here in case anyone ran into this ticket and thought it was still an issue.

I was able to install a custom package inside my package.json by using

"botkit-storage-mongo": "git+https://github.com/dakotasmith/botkit-storage-mongo.git#update-monk"

So I’d say it’s fixed!

4 Likes

I think using git urls is not working at this point. I can add it to the package.json and the log says things were installed but the module fails to resolve.

Using the console and navigating to node_modules I can see that the git-based dependency is not there. If I manually run npm install the dependency seems to be downloaded correctly.

Edit: And adding a new dependency seems to cause the downloaded git repo to vanish, I have to manually run npm install again.

Edit 2: Changed my start command to "start": "npm install && node server.js" as a workaround

Preety much its the issue the node or npm version.
As I had some similar issue earlier, but when I downgraded my node version it happened to get fixed.
I hope that helps ya out.

@Froosty is right, there is a bug with the latest npm versions that makes npm prune not work correctly with git-based dependencies. After the install step, we always run an npm prune to free up some space.

We are working on a possible solution for the issue, we’ll keep you posted :slight_smile: In the meantime, the workaround proposed by @Froosty should work!

Good news! We just deployed a change that should fix this issue for every node version.

Let us know if the problem is actually solved :slight_smile:

cc: @Froosty

Its an Awesome news.

Looks like it is working for me! Thank you @etamponi

1 Like

Unfortunately I’m having the same issue as described by rajsite above on Feb 4.

I have forked an npm package called “rheostat” onto my personal Github account. It’s located here: https://github.com/MattSidor/rheostat

I added it to my package.json file like this:

"dependencies": {
  ...
  "rheostat": "git+https://git@github.com/MattSidor/rheostat.git",
  ...
},

It appeared to install correctly, but when I try to import the package, I get this error: Module not found: Error: Can't resolve 'rheostat' in '/app/src'.

Here is my full Glitch project: https://glitch.com/edit/#!/rheostat-focus-outline-demo

What is the node version you are on??
And also can you do npm ls package_name in console?

Sorry, I’m really new to Glitch. How do I check the node version from the Glitch Console? It’s not listed in my package.json file, unfortunately.

This is the result I get when I type pnpm ls rheostat in Glitch Console:

rheostat-focus-outline-demo@1.0.0 /app
└── rheostat@github.com/MattSidor/rheostat/d5553de1a2c6e1e47d5c0de77a96e7967d90c859

You know what, I just typed node -v in the console and I think I got the result: v6.13.1

You can usually find it in your package.json:

"engines": {
    "node": "8.x"
  },

If it’s missing, you can add it and your app will restart and run with the node version specified. :smiley:

As you’ve found, node -v works, but if it’s not specified in package.json then it may automatically upgrade at some point in the future.

Hey @MattSidor!

Yep, using node -v in the console is one way to do it. But like @jude said you can easily download any version of Node in your package.json file.

I’m sure you know how to do it as it’s really simple to do.

So now that I know what node version I’m running, how is it relevant to the Module not found error I’m getting for my github package?

The Module not found error is talking about the Node packages, so make sure you’ve told your project to download them in your package.json file:

"dependencies": {
  "express": "^4.16.3"
}

If I’m wrong and it’s not talking about your packages, could you send me a screenshot or copy & paste the error over?

I think you must have missed my original post on this topic. Here is a link to it, also you can scroll up to see it: Install package.json dependency from git, not npm

Oh, my bad! I’ve never tried grabbing packages from GitHub, but I found this and I think it might help.

If not, I’m sorry! Again, I’ve never installed dependencies from GitHub repositories.

I think I’m following the procedure correctly. The problem is that the Glitch platform does not seem to be installing them correctly. That’s the topic of this whole thread.