Run a Vue.js project in server without " npm run dev " command?
Solution 1
It's not Vue specific but you also should be able to run npm run build
which generates production bundles in /dist
subfolder of your project. You are supposed to copy this folder to the production server and configure the server so that it serves dist/index.html
for every URL.
Solution 2
If you are using the "webpack", "webpack-simple" or "pwa" template there is a dedicated command for creating the production build, which allows a static hosting (with no need to run any npm process in the server):
npm run build
It will create a dist
folder which content you can upload to the root of your server.
Some more info about:
"webpack" template: https://vuejs-templates.github.io/webpack/commands.html#npm-run-build
"webpack-simple": https://github.com/vuejs-templates/webpack-simple#webpack-simple
- "pwa": https://github.com/vuejs-templates/pwa#whats-included
Sandip Nag
Updated on June 17, 2022Comments
-
Sandip Nag almost 2 years
After installing vue cli globally by running
npm install -g vue-cli
, I have installed all the modules in the project folder "myBlog" by runningnpm install
and can run the project in my local environment by usingnpm run dev
. But when I am going to move this project in the live server is this is the right way to run the batch program (npm run dev
) continuously or there are other ways to run the project without runningnpm run dev
continuously?