Search code examples
gitnpmdependenciesversioningpackage.json

NPM install/update: Getting the latest version without having to alter package.json with Git repository


The dependencies in my package.json look like this:

  "dependencies": {
    "shared-styleguide": "git+https://oauth2:[email protected]/project/shared-styleguide#master",
    "handlebars": "github:wycats/handlebars.js",
    "underscore": "^1.9.2"
  }

There are constantly changes to the "shared styleguide" package. Whenever I do npm i or npm update the shared styleguide package is not updated. I have to remove the #master and do npm update (nothing happens) and then I have to add the #master in the end and do npm update again to finally get the latest version. This is a also a problem for the deployment workflow as it seems like cached old versions of the styleguide library are used sometimes.

How can I write this into my package.json to get always the latest version of the master?


Solution

  • Found an acceptable - still not good workaround: Specify the commit hash within the package.json.

    "dependencies": {
        "shared-styleguide": "git+https://oauth2:[email protected]/project/shared-styleguide#bf6947b3a4c4334072c6dd96bd61b0893d1cb69c",
        "handlebars": "github:wycats/handlebars.js",
        "underscore": "^1.9.2"
      }
    

    More Info:

    What are commit-ish and tree-ish in Git?

    npm install from Git in a specific version

    Better solutions are still welcome.