Procedure to build a development environment for Vue.js with Docker - Qiita
Based on the above article, we are building a Vue environment using docker.
docker build --tag zatu:latest --file Dockerfile.
Create an image in the and
docker run --rm-it --name zatu1-p 8080:8080-v${PWD}:/zatubako-v/zatubako/node_modules zatu:latest
tried to start the container in , but received the following error:
npm ERR!code ENOENT
npm ERR!syscall open
npm ERR!path/zatubako/package.json
npm ERR!errno-2
npm ERR! enoent ENOENT: no such file or directory, open'/zatubako/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
US>npm ERR!A complete log of this run can be found in:
npm ERR!/root/.npm/_logs/2020-05-21T08_57_53_482Z-debug.log
I hope you enjoy it.
Dokcerfile
FROM node: 10.17.0-alpine 3.9
WORKDIR/zatubako
COPY package*.json./
RUN npm install
CMD ["npm", "run", "serve" ]
Directory Configuration
.
├-- zatubako Corporation
│ -- --babel.config.js
│ -- -- dist
│ -- --node_modules
│ │ └── ...
│ -- --package.json
│ -- --public
│ │ f --favicon.ico
│ │ -- index.html
│ -- -- README.md
│ -- -- src
├-- ├── README.md
└-- dockerfile
├-- .dockerignore
└-- docker-compose.yml
Package.json
{
"name": "zatubako",
"description": "AVue.js project",
"version": "1.0.0",
"author":",
"license": "MIT",
"private"—true,
"scripts": {
"dev": "cross-env NODE_ENV = development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"dependencies": {
"vue": "^2.5.11"
},
"browserslist":[
">1%",
"last 2 versions",
"note<=8"
],
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.0",
"babel-preset-stage-3": "^6.24.1",
"cross-env": "^5.0.5",
"css-loader": "^0.28.7",
"file-loader": "^1.1.4",
"vue-loader": "^13.0.5",
"vue-template-compiler": "^2.4.4",
"webpack": "^3.6.0",
"webpack-dev-server": "^2.9.1"
},
{
"scripts": {
"serve": "node_modules/.bin/vue-cli-service serve"
}
}
}
The directory you are mounting appears to be incorrect.
Since you are probably running docker run
in the Dockerfile location, the location of package.json can be found in zatubako/package.json
.
In other words, the execution command should look like this:
docker run --rm-it --name zatu1-p 8080:8080-v${PWD}/zatubako:/zatubako-v/zatubako/node_modules zatu:latest
package.json is causing a JSON syntax error.The correct answers are as follows:
{
"name": "zatubako",
"description": "AVue.js project",
"version": "1.0.0",
"author":",
"license": "MIT",
"private"—true,
"scripts": {
"dev": "cross-env NODE_ENV = development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"dependencies": {
"vue": "^2.5.11"
},
"browserslist":[
">1%",
"last 2 versions",
"note<=8"
],
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.0",
"babel-preset-stage-3": "^6.24.1",
"cross-env": "^5.0.5",
"css-loader": "^0.28.7",
"file-loader": "^1.1.4",
"vue-loader": "^13.0.5",
"vue-template-compiler": "^2.4.4",
"webpack": "^3.6.0",
"webpack-dev-server": "^2.9.1"
},
"scripts": {
"serve": "node_modules/.bin/vue-cli-service serve"
}
}
© 2024 OneMinuteCode. All rights reserved.