question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to find 'vue-cli-service' command in linux container on win 10 host

See original GitHub issue

Version

3.4.1

Environment info

Linux container on windows 10 host

Steps to reproduce

docker file

FROM node:latest

#ARG NODE_ENV
#ENV NODE_ENV=dev

ENV CONTAINER_PATH /var/www/myapp

WORKDIR $CONTAINER_PATH

COPY package*.json ./

# # install project dependencies
#RUN npm install -g @vue/cli-service-global
RUN npm install

#RUN yarn

EXPOSE 8080

# Start the app
CMD npm run serve

docker-compose.yml

version: '3'
services:
  web:
    container_name: myapp
    image: myapp
    build:
      context: .
      dockerfile: .docker/node.development.dockerfile
    volumes:
      - .:/var/www/myapp
    ports:
      - "8080:8080"

What is expected?

when i run the app locally, vue-cli-service serve works. it should work in container as well

What is actually happening?

vue-cli-service command not found


@vue/cli-service”: “^3.4.1”, is part of dev-dependency

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

33reactions
sodateacommented, Feb 25, 2019

The problem lies in your dockerfile

  1. You forgot to add this line COPY . . before serving the app. So the project files were not added to the container…
  2. vue-cli-service is a project local command residing in node_modules/.bin so you need to run it with npx vue-cli-service serve or npm run serve
  3. And you need to use the exec form of CMD: CMD ["npm", "run", "serve"]
  4. And it’s not recommended to set NODE_ENV in your environment (https://cli.vuejs.org/guide/mode-and-env.html#modes) . Even if you do need, we use development rather than dev for dev builds.
  5. Lastly, we need to expose the node_modules to the host by adding this to the docker-compose.yml:
    volumes:
      - .:/var/www/docker-vue
+     - /var/www/docker-vue/node_modules

Here’s the full updated docker-compse.yml:

version: '3'
services:
  web:
    container_name: docker-vue
    image: docker-vue
    build:
      context: .
      dockerfile: .docker/node.development.dockerfile
    volumes:
      - .:/var/www/docker-vue
      - /var/www/docker-vue/node_modules
    environment:
      - npm_config_unsafe_perm=true
    ports:
      - "8080:8080"

dockerfile:

FROM node:10.15.0

ENV CONTAINER_PATH /var/www/docker-vue

WORKDIR $CONTAINER_PATH

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 8080

CMD ["npm", "run", "serve"]
0reactions
sodateacommented, Dec 23, 2020

@Rocking80 This StackOverflow post explains it well: https://stackoverflow.com/a/32785014/2302258

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to solve 'vue-cli-service' is not recognized as an internal ...
I think you are using cmd in windows. Try deleting the node_modules folder and after that run npm i from the cmd.
Read more >
Installing and working with the devcontainer CLI
This topic covers the development container command-line interface (dev container CLI), which allows you to build and manage development containers, ...
Read more >
Dockerizing a Vue.js application - Shekhar Gulati
To build the Docker image, please run the following command. 1. docker build -t myapp . Now, you can ...
Read more >
Get started with Vuetify
This command will make changes to your project template files, components folder, vue.config.js, etc. If you are installing Vuetify via ...
Read more >
Docker VueJS Example | DevOps Junction
Docker VueJS Example · Step 1: Creating a Dockerfile · Step 2: Build a Docker Vue JS Image using Dockerfile · Step 3:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found