Npm install won't run on CircleCI, but works well locally

npm

#1

npm install fails on CircleCI. It works when package-lock.json is deleted, it also works well locally.

Local npm v 6.4.1
Local node v 8.9.4

Edit: Temporarily fixed by adding --no-package-lock flag to npm install.

#!/bin/bash -eo pipefail
cd server && npm install && npm test
npm WARN tar ENOENT: no such file or directory, open '/home/circleci/project/server/node_modules/.staging/tweetnacl-36945da5/nacl.js'
npm WARN tar ENOENT: no such file or directory, open '/home/circleci/project/server/node_modules/.staging/ajv-5a53a93d/dist/ajv.min.js'
npm WARN tar ENOENT: no such file or directory, open '/home/circleci/project/server/node_modules/.staging/aws-sdk-df7c9c11/clients/iotjobsdataplane.d.ts'
npm WARN tar ENOENT: no such file or directory, open '/home/circleci/project/server/node_modules/.staging/aws-sdk-df7c9c11/clients/costexplorer.d.ts'
npm WARN tar ENOENT: no such file or directory, open '/home/circleci/project/server/node_modules/.staging/blessed-db980a19/usr/fonts/ter-u14n.json'
npm WARN tar ENOENT: no such file or directory, open '/home/circleci/project/server/node_modules/.staging/sinon-37a8bb15/pkg/sinon-no-sourcemaps-2.4.1.js'
npm WARN tar ENOENT: no such file or directory, open '/home/circleci/project/server/node_modules/.staging/text-encoding-9cca0102/lib/encoding.js'
npm ERR! code E404
npm ERR! 404 Not Found: har-validator@5.1.2

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/circleci/.npm/_logs/2018-12-10T07_02_26_072Z-debug.log
Exited with code 1

cofig.yml

version: 2

jobs:
  server_tests:
    docker:
      - image: circleci/node:8-browsers
    steps:
      - checkout
      - run: cd server && npm install && npm test

  client_tests:
    docker:
      - image: circleci/node:8-browsers
    environment:
      - CHROME_BIN: "/usr/bin/google-chrome"
    steps:
      - checkout
      - run: cd client && npm install && npm run unit

  integration_tests:
    machine:
      docker_layer_caching: true
    steps:
      - checkout
      - run: cd test/integration && ./test.sh

  build_and_push:
    machine:
      docker_layer_caching: true

    steps:
      - checkout
      - run: script/build_and_push.sh

  deploy:
    machine:
      docker_layer_caching: true
    steps:
      - checkout
      - run: sudo apt-get -y -qq update
      - run: sudo apt-get install python-pip python-dev build-essential
      - run: sudo pip install urllib3==1.22 awsebcli --upgrade
      - run: script/deploy.sh mangosteen-staging

workflows:
  version: 2
  the_whole_shebang:
    jobs:
      - client_tests
      - server_tests
      - integration_tests
      - build_and_push:
          requires:
            - client_tests
            - server_tests
            - integration_tests
      - deploy:
          requires:
            - build_and_push
          filters:
            branches:
              only:
                - master

#2

It sounds like your package.json and package-lock.json may be out of sync. Have you recently installed new packages? Before committing your changes next time, could you run npm update locally? You could also add this to your config file before the install for good measure.

This was a common issue with an older version of NPM but I do not quite understand why you are experiencing this. There is somewhat of a general consensus online that the package-lock.json file should not be used due to the issues like this users have experienced.


#3

I have updated npm recently and have been experiencing issues with package-lock file.

Thanks, I will do npm update and will probably keep --no-package-lock flag on.