Docker: Install npm

I’m having a problem in the “Running Commands” section of ‘Building Images’ at “RUN npm install”. I’m getting the following error:

=> ERROR [4/4] RUN npm install 10.3s

[4/4] RUN npm install:
#8 10.26 npm ERR! code CERT_NOT_YET_VALID
#8 10.26 npm ERR! errno CERT_NOT_YET_VALID
#8 10.26 npm ERR! request to https://registry.npmjs.org/semver/-/semver-6.3.0.tgz failed, reason: certificate is not yet valid
#8 10.30
#8 10.30 npm ERR! A complete log of this run can be found in:
#8 10.30 npm ERR! /root/.npm/_logs/2021-04-04T14_28_29_647Z-debug.log

I did a google search on the error, which said the error is because the date/time is wrong. I ran the ‘date’ command, and the date/time is showing Sun Apr 4 14:52:46 UTC 2021, making the alpine date a week behind the system date/time.

I’ve tried to update the container date/time, but it isn’t working, saying the /etc/timezone directory doesn’t exist. Does anyone have a way to sync the container date/time to the system date/time?

@LyndaM,

Can you post your current working directory and the content of it.

root@DESKTOP-DHQ:/mnt/c/source/repos/UltimateDocker/react-app# ls -la
total 1148
drwxrwxrwx 1 root root 512 Apr 10 2021 .
drwxrwxrwx 1 root root 512 Apr 10 2021 …
-rwxrwxrwx 1 root root 15 Apr 10 2021 .dockerignore
drwxrwxrwx 1 root root 512 Apr 10 2021 .git
-rwxrwxrwx 1 root root 310 Apr 10 2021 .gitignore
-rwxrwxrwx 1 root root 179 Apr 10 2021 Dockerfile
-rwxrwxrwx 1 root root 3362 Apr 10 2021 README.md
drwxrwxrwx 1 root root 512 Apr 10 2021 node_modules
-rwxrwxrwx 1 root root 657980 Apr 10 2021 package-lock.json
-rwxrwxrwx 1 root root 813 Apr 10 2021 package.json
drwxrwxrwx 1 root root 512 Apr 10 2021 public
drwxrwxrwx 1 root root 512 Apr 10 2021 src
-rwxrwxrwx 1 root root 507430 Apr 10 2021 yarn.lock
root@DESKTOP-DHQ:/mnt/c/source/repos/UltimateDocker/react-app# pwd
/mnt/c/source/repos/UltimateDocker/react-app
root@DESKTOP-DHQ:/mnt/c/source/repos/UltimateDocker/react-app#