working with Laravel Vue js. but when I try to start vue js using npm run serve command. it is en counting following error command in my cmd .
npm ERR! Missing script: "serve"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run
how could I fix this problem?
package.json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --disable-host-check --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"axios": "^0.24.0",
"cross-env": "^7.0",
"laravel-mix": "^6.0.39",
"lodash": "^4.17.19",
"resolve-url-loader": "^3.1.0",
"sass": "^1.15.2",
"sass-loader": "^8.0.0",
"vue-template-compiler": "^2.6.14"
},
"dependencies": {
"vue": "^2.6.14",
"vue-axios": "^3.3.7",
"vue-router": "^3.5.2",
"vue-sweetalert2": "^5.0.2"
}
}
CodePudding user response:
Check if you have the below content inside the package.json
, if not add it and then try running the commands
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
// other commands
},
Edit:
If you are using cmd
in windows.
Follow the below steps
Try deleting the node_modules folder and after that run
npm i
from the cmd.Then try running
npm run serve
again and see if it works this timeif the above two steps don't work then install vue/cli service globally by running the command
npm install @vue/cli-service -g
and then follow step 1 and 2 sequentially
CodePudding user response:
This is not only vue js app. you are using vue
with Laravel
If you want to create production build you have to run npm run prod
.
If you working local then you should use npm run watch
. it will use hot reload so it will detect file changes and create complied filed.
Note : you have to add resourse js & css file to webpack.mix.js file and define the destination to store complied file in public folder.
You don't have to use npm run serve
because you are using vue js in laravel.