Reputation: 393
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"
}
}
Upvotes: 1
Views: 11258
Reputation: 1
I did every steps and when i run npm run serve i got this: PS C:\WINDOWS\System32\WindowsPowerShell\v1.0> npm run serve npm ERR! Missing script: "serve" npm ERR! npm ERR! To see a list of scripts, run: npm ERR! npm run
npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Make Users\AppData\Local\npm-cache_logs\2023-01-23T15_13_24_934Z-debug-0.log
Upvotes: 0
Reputation: 620
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.
Upvotes: 1
Reputation: 4684
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 time
if 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
Upvotes: 0