Nodejs package missing

javascript
nodejs

#1

I’ve got a react ui building in CircleCI, however a developer has added a package, which isn’t being picked up by circleci, I’ve tried overriding the npm install part of the build process, I’ve removed node_modules from the cache, I’ve done none cached builds etc. But nothing seems to work.

machine:
  node:
    version: 8.1.0
  environment:
    GCLOUD_PROJECT_NAME: <redacted>
    GCLOUD_CLUSTER_NAME: dev
    CLOUDSDK_COMPUTE_ZONE: europe-west1-b
    DOCKER_TAG_PREFIX: "eu.gcr.io/$GCLOUD_PROJECT_NAME/ocp"
    DOCKER_TAG: "$DOCKER_TAG_PREFIX:$CIRCLE_SHA1"
    GOOGLE_APPLICATION_CREDENTIALS: ${HOME}/gcloud-service-key.json
  services:
    - docker
dependencies:
  pre:
    - cat package.json
    - sudo /opt/google-cloud-sdk/bin/gcloud --quiet components update --version 149.0.0
    - sudo /opt/google-cloud-sdk/bin/gcloud --quiet components update --version 149.0.0 kubectl
    - echo $GCLOUD_SERVICE_KEY | base64 --decode -i > ${HOME}/gcloud-service-key.json
    - sudo /opt/google-cloud-sdk/bin/gcloud auth activate-service-account --key-file ${HOME}/gcloud-service-key.json
    - sudo /opt/google-cloud-sdk/bin/gcloud config set project $GCLOUD_PROJECT_NAME
    - sudo /opt/google-cloud-sdk/bin/gcloud --quiet config set container/cluster $GCLOUD_CLUSTER_NAME
    - sudo /opt/google-cloud-sdk/bin/gcloud config set compute/zone ${CLOUDSDK_COMPUTE_ZONE}
    - sudo /opt/google-cloud-sdk/bin/gcloud --quiet container clusters get-credentials $GCLOUD_CLUSTER_NAME
    - sudo chown -R ubuntu:ubuntu /home/ubuntu/.kube
test:
  override:
    - exit 0
deployment:
  production:
    branch: ['master']
    commands:
      - cp ./public/js/env.production ./public/js/env.js
      - cp ./config.production ./config.js
      - docker build -t $DOCKER_TAG .
      - docker tag "$DOCKER_TAG" "$DOCKER_TAG_PREFIX:latest"
      - sudo /opt/google-cloud-sdk/bin/gcloud docker -- push $DOCKER_TAG
      - sudo /opt/google-cloud-sdk/bin/gcloud docker -- push "$DOCKER_TAG_PREFIX:latest"
      - kubectl --namespace=production patch deployment ocp-production -p '{"spec":{"template":{"spec":{"containers":[{"name":"ocp","image":"'"$DOCKER_TAG"'"}]}}}}'
  staging:
    branch: ['develop', 'development']
    commands:
      - cp ./public/js/env.staging ./public/js/env.js
      - cp ./config.staging ./config.js
      - docker build -t $DOCKER_TAG .
      - docker tag "$DOCKER_TAG" "$DOCKER_TAG_PREFIX:develop"
      - sudo /opt/google-cloud-sdk/bin/gcloud docker -- push $DOCKER_TAG
      - sudo /opt/google-cloud-sdk/bin/gcloud docker -- push "$DOCKER_TAG_PREFIX:develop"
      - kubectl --namespace=staging patch deployment ocp-staging -p '{"spec":{"template":{"spec":{"containers":[{"name":"ocp","image":"'"$DOCKER_TAG"'"}]}}}}'

My package.json…

{
  "name": "tabb-ocp",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www",
    "dev": "NODE_ENV=development node ./bin/www"
  },
  "dependencies": {
    "@google-cloud/storage": "^1.1.1",
    "bcrypt-nodejs": "0.0.3",
    "body-parser": "~1.16.0",
    "cookie-parser": "~1.4.3",
    "debug": "~2.6.0",
    "express": "~4.14.1",
    "express-jwt": "^5.1.0",
    "express-unless": "^0.3.0",
    "jsonwebtoken": "^7.3.0",
    "mailgun-js": "^0.10.1",
    "mongodb": "^2.2.25",
    "mongoose": "*",
    "multer": "^1.3.0",
    "pug": "~2.0.0-beta10",
    "request": "^2.81.0",
    "stripe": "^4.22.0"
  },
  "devDependencies": {
    "gulp": "^3.9.1",
    "gulp-csso": "^3.0.0"
  },
  "pugLintConfig": {
    "extends": "./node_modules/coding-standard/.pug-lintrc",
    "disallowIdLiterals": null
  }
}

The Dockerfile…

FROM node:8.1-alpine

RUN mkdir -p /usr/app

COPY . /usr/app

WORKDIR /usr/app

ENV PORT 3000

CMD ["npm", "start"]

And the error…

Error: Cannot find module '@google-cloud/storage'


#2

I think you forgot to setup the directory for express:

express
Once you do that you should be able to see a bunch of files, you should then run the command:

npm install -d
Regards.
Saanvi


#3