npm error in docker tutorial

Official Docker documentation

An error occurred in Docker document Quickstart part2 In the part of $ docker build --tag bulletinboard: 1.0 .

Step 4/7 : RUN npm install
 ---> Running in 1a42d2b3c5dd
npm notice
npm notice New patch version of npm available! 7.0.3 -> 7.0.8
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.0.8>
npm notice Run `npm install -g [email protected]` to update!
npm notice
npm ERR! code FETCH_ERROR
npm ERR! errno FETCH_ERROR
npm ERR! invalid json response body at https://registry.npmjs.org/vue reason: Unexpected token � in JSON at position 70253

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-11-05T12_02_36_331Z-debug.log

What I did 1

Install Node.js and npm directly Installation method After installation, set at the following site How to check the Path of Node.js [for beginners] Also, control panel> system> advanced system settings (lower left)> environment variables> edit the path of system variables and add C: \ Program Files \ nodejs \ (maybe it is done automatically)

What I did 2

Delete the package-lock.json file in the bulletin-board-app file Run $ docker build --tag bulletinboard: 1.0 .

I still got the error, so on line 5 of the dockerfile RUN npm cache verify



FROM node:current-slim

WORKDIR /usr/src/app
COPY package.json .
RUN npm cache verify
RUN npm install 

EXPOSE 8080
CMD [ "npm", "start" ]

COPY . .

Did it work?

$ docker build --tag bulletinboard:1.0 .
Sending build context to Docker daemon  12.03MB
Step 1/8 : FROM node:current-slim
 ---> 922b09b21278
Step 2/8 : WORKDIR /usr/src/app
 ---> Using cache
 ---> 5d3d82eda8ed
Step 3/8 : COPY package.json .
 ---> Using cache
 ---> 7cc831630440
Step 4/8 : RUN npm cache verify
 ---> Using cache
 ---> 54aab39eb76b
Step 5/8 : RUN npm install
 ---> Using cache
 ---> b6e782bc92e7
Step 6/8 : EXPOSE 8080
 ---> Using cache
 ---> baf0c121f375
Step 7/8 : CMD [ "npm", "start" ]
 ---> Using cache
 ---> 5fcb2b27e8f0
Step 8/8 : COPY . .
 ---> b02d075c5110
Successfully built b02d075c5110
Successfully tagged bulletinboard:1.0
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.

Last Ignore SECURITY WARNING: ~~~~

Conclusion

It is better to acquire more knowledge of Node.js etc.

Recommended Posts

npm error in docker tutorial
docker tutorial (memo)
Docker in LXD
docker error delete command
Error handling in Graphql-ruby
Migration error after Activerecord association in Rails5 + Docker environment (2)
[Ruby on Rails Tutorial] Error in the test in Chapter 3
Migration error after Activerecord association in Rails5 + Docker environment
Avoid Yubaba's error in Java
NameError in Income # index error
Install yarn in docker image
ActiveRecord :: NotNullViolation in Devise error
Fixed NVIDIA Docker related signature invalid error in apt update
Error in rails db: migrate
Error in Spring database connection
[Docker] The story that an error occurred in docker-compose up
What to do if you get a gcc error in Docker
Error "MySQL said: Protocol mismatch; server version = 11, client version = 10" in Docker x MySQL8
I got a Permission Denied error when I put Laravel in Docker
Error when npm install on Windows 7
Let's summarize Docker in an atmosphere
About Invalid Request Error in Payjp
General error: 1812 occurs with docker + laravel
411 Error: Length Required in SOAP communication
Error handling in gRPC (Kotlin version)
Install laravel/Dusk in docker environment (laravel6)
Hit the Docker API in Rust
Error in ./gradlew: Symbol not found
Error summary in bundle install. memorandum
Error encountered in tagging function implementation
Check MySQL logs in Docker environment
Email sending error "dh key too small" in Redmine's official Docker Image