Npm notice created a lockfile as package-lock.json. You should commit this file

I’m trying to update a build and have come across this error each time I try to update the build.

npm notice created a lockfile as package-lock.json. You should commit this file.

I’ve tried etching a new img and renaming everything but I get the same error on fresh builds?!

Here’s a few more lines f the error;

npm ERR! As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use ‘npm cache verify’ instead.
[Build] npm ERR!
[Build] npm ERR! If you’re sure you want to delete the entire cache, rerun this command with --force.
[Build]
[Build] npm ERR! A complete log of this run can be found in:
[Build] npm ERR! /root/.npm/_logs/2017-06-22T00_31_34_387Z-debug.log

Can you share your dockerfile please so we can reproduce and suggest a fix. Thanks

@joe

Apologies, the link I posted as my second comment gave me the fix;

Updating;
RUN JOBS=MAX npm install --production --unsafe-perm && npm cache clean && rm -rf /tmp/*

to;
RUN JOBS=MAX npm install --production --unsafe-perm && npm cache verify && rm -rf /tmp/*

New Docker file;

    # base-image for node on any machine using a template variable,
    # see more about dockerfile templates here: http://docs.resin.io/deployment/docker-templates/
    # and about resin base images here: http://docs.resin.io/runtime/resin-base-images/
    # Note the node:slim image doesn't have node-gyp
    FROM resin/%%RESIN_MACHINE_NAME%%-node:slim

    # use apt-get if you need to install dependencies,
    # for instance if you need ALSA sound utils, just uncomment the lines below.
    RUN apt-get update && apt-get install -yq \
        python-motephat curl && \
        apt-get clean && rm -rf /var/lib/apt/lists/*

    # Defines our working directory in container
    WORKDIR /usr/src/app

    # Copies the package.json first for better cache on later pushes
    COPY package.json package.json

    # This install npm dependencies on the resin.io build server,
    # making sure to clean up the artifacts it creates in order to reduce the image size.
    RUN JOBS=MAX npm install --production --unsafe-perm && npm cache verify && rm -rf /tmp/*

    # This will copy all files in our root to the working  directory in the container
    COPY . ./

    # Enable systemd init system in container
    ENV INITSYSTEM on

    # server.js will run when container starts up on the device
    CMD ["python", "lightbox.py"]

I’m still receiving the following notice in the build log;
e[34m[Build] e[39m e[91mnpme[0me[91m e[0me[91mnoticee[0me[91m created a lockfile as package-lock.json. You should commit this file.

Thanks
Nathaniel

Great, we will get this fixed in the docs ASAP.

Thanks

@joe looking at this line;

apt-get clean && rm -rf /var/lib/apt/lists/*

Should this be amended to;

apt-get verify && rm -rf /var/lib/apt/lists/*

Do you have any hints on how I should commit/remove the lockfile to address that issue on build?

The apt-get line should not be changed.
Can you post the full build output please as the formatting got a bit messed up before.

No problem, here’s the successful build log;

e[36m[Info] e[39m Starting build for nathanielchang/new1, user nathanielchang
e[36m[Info] e[39m Dashboard link: https://dashboard.resin.io/apps/424280/devices
e[36m[Info] e[39m Building on ‘local’
[==================================================>] 100%

e[32m[Success] e[39m Cached image pulled in 1 second
e[36m[Info] e[39m Dockerfile template application detected

[==================================================>] 100%

e[32m[Success] e[39m Base image pulled
e[36m[Info] e[39m Starting Dockerfile build
e[34m[Build] e[39m Step 1 : FROM resin/raspberry-pi-node:slim
e[34m[Build] e[39m —> 8430a434b326
e[34m[Build] e[39m Step 2 : RUN apt-get update && apt-get install -yq python-motephat curl && apt-get clean && rm -rf /var/lib/apt/lists/*
e[34m[Build] e[39m e[42me[30mUsing cachee[39me[49m
e[34m[Build] e[39m —> 45e7be5a6ef4
e[34m[Build] e[39m Step 3 : WORKDIR /usr/src/app
e[34m[Build] e[39m e[42me[30mUsing cachee[39me[49m
e[34m[Build] e[39m —> 3b5aa697527c
e[34m[Build] e[39m Step 4 : COPY package.json package.json
e[34m[Build] e[39m e[42me[30mUsing cachee[39me[49m
e[34m[Build] e[39m —> 204f4fc0f61f
e[34m[Build] e[39m Step 5 : RUN JOBS=MAX npm install --production --unsafe-perm && npm cache verify && rm -rf /tmp/*
e[34m[Build] e[39m —> Running in e87b9fd30563
e[34m[Build] e[39m e[91mnpme[0me[91m e[0me[91mnoticee[0me[91m created a lockfile as package-lock.json. You should commit this file.
e[34m[Build] e[39m e[0mup to date in 1.63s
e[34m[Build] e[39m Cache verified and compressed (~/.npm/_cacache):
e[34m[Build] e[39m Content verified: 0 (0 bytes)
e[34m[Build] e[39m Index entries: 0
e[34m[Build] e[39m Finished in 0.248s
e[34m[Build] e[39m —> 1b5753e1db0e
e[34m[Build] e[39m Removing intermediate container e87b9fd30563
e[34m[Build] e[39m Step 6 : COPY . ./
e[34m[Build] e[39m —> 93857cbb9219
e[34m[Build] e[39m Removing intermediate container bb944a85144f
e[34m[Build] e[39m Step 7 : ENV INITSYSTEM on
e[34m[Build] e[39m —> Running in 7093d7d94ade
e[34m[Build] e[39m —> 7cde3218f4e4
e[34m[Build] e[39m Removing intermediate container 7093d7d94ade
e[34m[Build] e[39m Step 8 : CMD python lightbox.py
e[34m[Build] e[39m —> Running in cf76d70501ae
e[34m[Build] e[39m —> 5abb9757ff61
e[34m[Build] e[39m Removing intermediate container cf76d70501ae
e[34m[Build] e[39m Successfully built 5abb9757ff61
e[32m[Success] e[39m Image created successfully
e[36m[Info] e[39m Verifying image integrity…
e[32m[Success] e[39m Image passed integrity checks!
[==================================================>] 100%

I think you have 2 choices, either ignore the error as your builds are being created successfully or run step 5 locally and commit the package-lock.json file that gets generated. If you go that route you will also need to modify step 4 to copy the file into the build.