Frequently getting npm 1.1.70 instead of correct installed version

nodejs
npm

#1

about 40-50% of our builds fail on npm install due to the fact that circle is trying to use an ancient version of npm to install deps (1.1.70).

from the npm step in the circle UI:

npm ERR! node -v v4.2.4
npm ERR! npm -v 1.1.70

it is using the correct node version as listed in our circle.yml and saying that it’s using the correct npm during the set node.js version to 4 task:

Downloading https://nodejs.org/dist/v4.2.4/node-v4.2.4-linux-x64.tar.xz...

######################################################################## 100.0%
WARNING: checksums are currently disabled for node.js v4.0 and later
Now using node v4.2.4 (npm v2.14.12)
default -> 4 (-> v4.2.4)

We are not installing npm 1.1.70 (it’s not listed in our package.json), and we are not changing the path at all during install.

Rebuilding without cache always makes it use the correct npm version. Is there anyway to clear the cache for the project entirely and have it save a correctly built cache?


#2

Hi there,

Can you please try following the instructions outlined here?

-Frank


#3

We actually already have npm install -g npm@2 in our circle.yml. Here’s the full copy:

machine:
  node:
    version: 4
  services:
    - elasticsearch
    - docker
dependencies:
  pre:
    - npm install -g npm@2
    - ./npmauth.sh
    - ./install-postgres-9.5.sh
    - sudo apt-get update
    - sudo apt-get purge -y postgresql-9.4 postgresql-server-dev-9.4
    - sudo apt-get install -y postgresql-9.5 postgresql-server-dev-9.5
    - sudo -H -u postgres bash -c 'createuser -d ubuntu'
    - sudo apt-get install -y --only-upgrade google-chrome-stable
    - sudo apt-get install -y graphicsmagick ghostscript poppler-utils
deployment:
  all:
    branch: /.*/
    commands:
      - ./deploy.sh

#4

Today literally EVERY build has failed due to this issue requiring someone to go and click “Rebuild without Cache”.

Any resolution to this would be amazing.


#6

Hi @toddself,

npm ERR! command "/home/ubuntu/nvm/versions/node/v4.2.4/bin/node" "/home/ubuntu/<redacted>/node_modules/.bin/npm" "install"

I’m still not sure what the underlying issue is here, but the output suggests that a locally installed version of npm is being used, so that explains why running npm install -g npm@2 does not help. My guess is that one of your dependencies is somehow installing this older version of npm as one of its dependencies. If you’re unable to figure out how to stop that from happening, you may be able to work around this by removing the -g flag from your npm install -g npm@2 command so that npm@2 is installed locally instead of globally.

Hope this helps!


#7

There no NPM being installed in the node_modules tree for this branch of the project. Here is the output from npm ls npm:

npm ls npm
scripto@1.0.0 /Users/todd/src/scripto2
└── (empty)

And just to verify the command does what you want it to do, here’s the results for acorn which our app does not directly rely upon, but rather it a dependency of a dependency

npm ls acorn
scripto@1.0.0 /Users/todd/src/scripto2
├─┬ babelify@6.1.3
│ └─┬ babel-core@5.8.34
│   └─┬ regenerator@0.8.40
│     └─┬ commoner@0.10.4
│       └─┬ detective@4.3.1
│         └── acorn@1.2.2
├─┬ browserify@10.2.6
│ ├─┬ insert-module-globals@6.6.3
│ │ └─┬ lexical-scope@1.2.0
│ │   └─┬ astw@2.0.0
│ │     └── acorn@1.2.2
│ ├─┬ module-deps@3.9.1
│ │ └─┬ detective@4.3.1
│ │   └── acorn@1.2.2
│ └─┬ syntax-error@1.1.4
│   └── acorn@1.2.2
├─┬ browserify-shim@3.8.12
│ └─┬ exposify@0.4.3
│   └─┬ replace-requires@1.0.3
│     └─┬ detective@4.1.1
│       └── acorn@1.2.2
└─┬ karma-browserify@4.4.2
  └─┬ browserify@10.2.3
    ├─┬ insert-module-globals@6.6.3
    │ └─┬ lexical-scope@1.2.0
    │   └─┬ astw@2.0.0
    │     └── acorn@1.2.2
    ├─┬ module-deps@3.9.1
    │ └─┬ detective@4.3.1
    │   └── acorn@1.2.2
    └─┬ syntax-error@1.1.4
      └── acorn@1.2.2

Why is the version from another branch appearing in the restored cache (especially a version which build extremely infrequently) appearing in this branch’s cache. That gives me a large concern for build dependency issues if cached installs from other branches are polluting each other. If we were working on upgrading a module version how can we be sure if building a branch with a different version is not interfering with this?


#8

So @frank – since we once had NPM installed on a branch that we haven’t built in over a month, we’re going to be stuck with this permanently in our cache?

We still have to choose rebuild without cache on every single new branch pushed up – branches that are based on a branch that does not include the old NPM dependency.

Is there anyway to make circle-ci drop this cached node_modules?

I know caching is one of those “hard” things from a computer science perspective, but this is pretty troubling if we’re getting back cached copies of node_modules from different branches that are super stale…


#9

Hi @toddself,

Can you please PM me the link to the project?

-Frank


#10