Guidelines for launching a Vue.js application in a production environment using the package-lock.json file

Looking to create a vue.js app for production using npm ci. Should the @vue/cli-service be placed in the devDependencies section of package.json before running

npm ci
vue-cli-service --mode production

Or should the @vue/cli-service be added to the dependencies section of package.json and then run

npm ci --production
vue-cli-service --mode production

Answer №1

As outlined in this resource:

  • "dependencies" : Necessary packages for your application in production.
  • "devDependencies" : Packages required only for local development and testing purposes.

If you examine how an application is initialized using vue cli, you'll find a basic package.json structure like this:

  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build"
  },
  "dependencies": {
    "core-js": "^3.6.5",
    "vue": "^3.0.0"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "@vue/compiler-sfc": "^3.0.0"
  }

Answer №2

When it comes to deploying your app, there are various approaches you can take. In my experience with Vue projects, I typically follow a two-step deployment process:

  1. First, build the app using vue-cli-service
  2. Next, deploy the app to your desired hosting platform

To streamline this process, it's useful to set up a "deploy" script in your package.json, like so:

"scripts": {
    "start": "npm run serve",
    "build": "vue-cli-service build",
    "deploy": "npm run build && ./deploy.sh",
  },
  "dependencies": {…

Your deploy.sh script would then handle all necessary steps for deployment. For more detailed instructions, refer to the Official Vue Documentation.

UPDATE: To answer your question - running npm run build as defined above is how you build a Vue app for production. For additional insights, check out the Documentation on Environment variables with vue-cli-service

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the process for creating a local repository for Node.js npm?

When it comes to the building process in node js, there are a few goals that need to be called: Begin by calling npm install, which creates a folder called node_modules and places all dependencies from package.json into it. [for UI development] Execute a ...

The Vue2 Leaflet map is being obstructed by the bottom navigation and app bar, making it difficult

One of the challenges I'm facing in my app is implementing Vue2 Leaflet. It seems to be getting overlapped by the elements v-bottom-navigation and v-app-bar. Could it be that the leaflet's height is too large? The code structure includes wrappin ...

Ways to address conflicts arising from peer dependencies

Greetings for taking the time to read this. After implementing some adjustments in my local development environment and encountering no issues, I pushed the changes to my test environment on AWS Amplify. Unfortunately, the build failed with the following ...

What steps should I take to troubleshoot and resolve the gulp-sass installation error

I'm having an issue with installing gulp-sass in my Gulp project. Unlike other packages like gulp-uglify, I am facing errors specifically with gulp-sass. I have tried re-installing and updating Node.js, but the problem persists. How can I resolve this ...

I'm having trouble installing axios using npm

I am in the process of developing an express app that will utilize IGDB's api, and I initially planned to use axios. However, upon attempting to install axios with npm, I encountered the following error: npm ERR! code EACCES npm ERR! syscall rename np ...

The setter of the computed property is failing to execute

Currently, I am working with a computed property that represents an object of a specific type defined within my Vuex Store. The goal is to utilize this property in my component using v-model. I have thoroughly set up getters and setters for this property a ...

What is the process for releasing an npm package without relying on any babel dependencies?

I am currently working on a npm project called moduleA which I plan to publish to the npm registry. This project utilizes javascript along with webpack4 and babel7. While moduleA functions properly on its own, I encountered some issues with babel when atte ...

Error: npm command not recognized in macOS Monterey

The error I'm encountering in macOS M2 is displayed below: https://i.stack.imgur.com/CztMZ.png ...

What is the best way to connect data so that when a user clicks on a specific card, it appears on a popup card

When a user clicks on any card containing data retrieved from a backend API GET method, that data should be displayed in a pop-up card. In my situation, I have two components: DisplayNotes.vue and UpdateNotes.vue. Whenever a user clicks on a displayed card ...

Get the excel file from the assets using vue.js

I need some help figuring out how to download an excel file from my vue.js project. I tried the following code: <template> <div class="row mt-5"> <a href="./assets/template.xlsx" target="_blank">Downloa ...

Streamlining the Compilation of Dependencies for Electron Application Distribution

I am currently exploring the best method to package and distribute various dependencies (such as node modules and client-side scripts/frameworks like Angular) with my Electron App. While the standard approach of npm install module-name --save is effective ...

Set the Vue 3 Select-Option to automatically select the first option as the default choice

I am attempting to set the first select option as the default, so it shows up immediately when the page loads. I initially thought I could use something simple like index === 0 with v-bind:selected since it is a boolean attribute to select the first option ...

The styling of the CSS is tailored to various breakpoints

source: Display helpers How can I dynamically change CSS styles based on the current breakpoint size? For example, can I set different sizes, positions, and colors for elements when the window is on xs compared to md or other breakpoints? ...

The file functions/lib/functions/src/index.ts is missing, preventing the deployment of Cloud Functions

Whenever I attempt to deploy my Firebase cloud functions, I encounter the following error. Expected outcome: Successful deployment of functions. Error: Error: An issue occurred while reading functions/package.json: functions/lib/index.js is missing and ...

Having trouble with a method that isn't providing values during interpolation in Nuxt.js/Vue

Within the static folder of my nuxtjs application, there exists a file named data.json Utilizing this data within my component is done as follows: <script> import data from '~/static/data.json'; export default { data ({ params }) { ...

How can Vue detect modifications made in the edited field?

I am facing an issue with tracking changes in a specific object. Here is the structure of the object: users: { email: '', password: '' } My goal is to detect any edits made to the keys within the users object and store the key ...

What is the correct method for routing Vue/AJAX requests in Laravel?

I am new to Laravel and creating a web service that can operate without the need for JavaScript, in case it is disabled by the user. However, I believe it would enhance the user experience if certain actions could be performed without having to refresh th ...

Is there a way to pass a v-modal as an array when setting Axios params?

I am currently dealing with a Vue Multiselect setup where the v-model is an array to accommodate multiple selected options. The challenge I am facing involves calling a route within the loadExtraOptions method and passing the array of IDs as a parameter ...

Azure pipeline: Command Line error: Bash exited with code '1'

While attempting to run my Cypress test using Azure Pipeline, I encountered the following problem: YAML file: # To configure triggers for Azure CI see # https://docs.microsoft.com/en-us/azure/devops/pipelines/build/triggers?view=azure-devops&tabs=yaml ...

Stopping the interval in Vue before the component is destroyed

I am currently facing an issue with a countdown timer implemented on a component. The timer functions properly, however, I want it to stop counting down once the user navigates away from the page where the component is located. I have attempted to use cl ...