I am trying to run vue/cli in a docker container.
I started the container went to cli of the container through docker exec -it
command and entered the command npm install @vue/cli
. Now, when I see the package.json file of the container, I see the package installed but when I try to create a project with the command vue create <project-name>
it shows vue command not found
.
{
"name": "node_dock_2",
"version": "1.0.0",
"description": "node with docker with vue.js",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"keywords": [
"website",
"Docker",
"vue.js",
"vue/cli"
],
"author": "Viraj",
"license": "ISC",
"dependencies": {
"@vue/cli": "^4.5.15",
"express": "^4.17.2"
}
}
This is the message when I try to install @vue/cli: (npm install @vue/cli
)
up to date, audited 943 packages in 12s
68 packages are looking for funding
run `npm fund` for details
14 vulnerabilities (6 moderate, 8 high)
To address issues that do not require attention, run:
npm audit fix
Some issues need review, and may require choosing
a different dependency.
Run `npm audit` for details.
This is my Dockerfile (Dockerfile, index.js and package.json are in same directory).
FROM node
WORKDIR /
COPY . .
RUN npm install
CMD ["node", "/index.js"]
What am I doing wrong?
From the error it seems like that your container does not have correct PATH to look for vue binary
It's essentially a : separated list of directories. When you execute a command, the shell searches through each of these directories, one by one, until it finds a directory where the executable exists
npm install -g @vue/cli
export PATH=$PATH:/root/.npm-global/bin
You should update your Dockerfile accordingly to make these changes permanent.