npm package from private github repo, install vs update (package.json) - node.js

I have already seen this question npm-install-vs-update-whats-the-difference
My question is around using install vs update for private github repo using git+ urls.
I have a private github repo which is used in the grunt. This repo receives frequent updates. I installed this repo using git+ssh url as mentioned here npm install git remote url
Everything works fine when installing. Problem comes when updating the package. As per my understanding and question mentioned above, npm updates the package to latest version when doing npm install but this doesnt seem to be case with package installed from github. I had to use npm update to get the latest version. I dont mind using npm update but I have observed that its slow compared to npm install. Can anyone put their thoughts why this might be happening.
My package.json looks like following
{
"name": "My Project",
"version": "1.0.0",
"dependencies": {
"grunt": "^0.4.5",
//Relevent package
"my-tasks": "git+ssh://git#github.com:Flutterbee/my-tasks.git"
}
}
PS : Using npm 3.3.3 (if that makes difference)

Can you try with specifying the branch name with in your package.json like this
"my-tasks": "git+ssh://git#github.com:Flutterbee/my-tasks.git#master"

Related

Why does npm install with git+ssh install differently than https?

What is the difference between installing a npm package via https and ssh? My expectation is that the downloaded package would be the same but this is not the case. For example:
// package.json
"dependencies": {
"lodash": "^4.17.19"
// vs
"lodash": "git#github.com:lodash/lodash.git#semver:^4.17.19"
}
When I use the first option, the actual npm package gets installed.
When I install via the second option, I get only the files that are whitelisted from the repo but not the actual package itself.
I don't see a good explanation in the npm documentation. Why aren't these installing the same thing? Is there a way to install the actual package via ssh and not the commit itself?
Two ways of installing dependencies.
From NPM repository itself (specify the version)
From github (specify a branch OR commit and tag)
It is advisable to publish to the registry the minified/compiled version of the library than the source unless it is necessary. So, it is possible that what you get from the NPM is different than the source repository itself.
It is really question of the "place" (npm or github) than the method (http or ssh)

How To Update Git Hash in npm package.json git project?

How do I specify exact git hash in package.json dependencies for a Github project, and have an easy way to upgrade it at the same time?
My package.json is as follow:
{
"name": "my faboulous app",
"version": "1.0.0",
"dependencies": {
// ...
"request": "request/request#5ee89063cd"
}
}
It relies on a Github project: https://github.com/request/request and uses specific revision which is 5ee89063cd.
I want to stick to specific version, so when someones clones my project and calls npm install she has the same request dependency version as me.
But at certain point in time, there comes an important bugfix for me, and I want to upgrade the revision in package.json to the newest version that is available at Github.
Is it possible to achieve this with npm update command? How can I upgrade the revision from command line, instead of manually editing the file?
My understanding is that, when I call npm install it always takes the hash that is specified in package.json. But when I call npm update I would like to have package.json request dependency updated to the latest repository version of it with the newest revision hash.
How can I achieve that? If not with npm update maybe there is the other simple way?
Update
Checkout the git-npm-updater package which can get the job done for you.
git-npm-updater automatically updates npm dependencies presented in your package.json and create pull requests to your git repo.
Hope this helps!

Unable to install latest version of a package that is in the NPM repo

I'm having issues with a NPM and couple of dependencies where the latest version of a package that NPM finds is different from the latest version that is actually present in the NPM repo.
I'm trying to install a package that has other dependencies, but I'm unable to because I get the "No matching version found for (package)#(version)" error. However, if I go to the NPM official site, I can see that there is in fact matching version for the package I need.
I've upgraded NPM to its latest version and I have also cleaned my NPM cache.
Edit: Some of the specific packages in question - gulp-chmod#^2.0.0, sanitize-filename#^1.6.1, generator-code#1.1.22
See if the adding the following key in package.json helps you!
"engines": {
"node": "8.1.1",
"npm": "5.0.3"
}
We can specify the node and npm version in the package.json file as shown above.
In getting the same error (for a package I just updated, typeson) and looking at my log, I see it is trying to access:
https://registry.npmjs.org/typeson
While this and https://www.npmjs.com/package/typeson are showing only up to 5.17.0, http://registry.npmjs.org/-/v1/search?text=typeson is showing the currently latest version, 5.18.0.
Maybe it can just take time to propagate through the site.
Update: In my case, it still wasn't working about an hour later, so I published a new version, and it was then immediately available.

Overwriting node dependencies with github forked repo: npm shrinkwrap...?

I am building an app with Angular 4 cli, using the Dragula drag-and-drop stystem ng2-dragula. I want to update to this particular forked repo which provides some specific augmentation.
But I am struggling to install this with node. I can't simply run
npm install git://github.com/nguyenj/dragula.git
I think because in the ng2-dragula package.json, the dependency is specified as
"dependencies": {
"dragula": "^3.7.2"
},
I have tried to address this using npm-shrinkwrap, using the solution posted here (See section The Real Solution)
But it isn't working; Even if I manually change the dependencies section of the ng2-dragula package.json, running npm install just installs the original dragula, NOT the version I want from https://github.com/nguyenj/dragula
Why? How can I solve this?
Actually, this was something quite simple- no need to be overwriting anything- I just needed to specify the branch of the forked repo:
npm install git://github.com/nguyenj/dragula.git#feature/axis

Update NPM Packages

I seem to understand how to clone a repository, but I'm not sure I'm fully grasping how to keep that repository current with what's on Github. I'm using Basscss for example, and I believe my local project is slightly out of date with what's on Github.
I'm trying to update Basscss to the latest version using npm updatebut even after running that command my package.json file remains the same with the version stuck at "4.2.1".
"name": "basscss",
"version": "4.2.1",
...
Am I doing something wrong here? Any help with this is appreciated. Thanks in advance!
npm update will update the module's files listed in your project. if you want to update your package.json file with the newer version. use the save option.
npm update --save
edit
npm install basscss#latest --save
I would try to re-install latest and save to package file. BTW, your package.json should reference the dep's like this:
"name" : "YOUR_PROJECT",
"version" : "0.0.1",
"dependencies": {
"basscss": "^4.2.4",
}

Resources