'npm run server throws error sh: 1: vue-cli-service: not found
I'm trying to setup an existing vue project and getting this error
admin@kali:/media/veracrypt1/themeforest-LSerfC0M-skote-vuejs-admin-dashboard-template/Admin$ npm run serve
> [email protected] serve /media/veracrypt1/themeforest-LSerfC0M-skote-vuejs-admin-dashboard-template/Admin
> vue-cli-service serve
sh: 1: vue-cli-service: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! [email protected] serve: `vue-cli-service serve`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] serve script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/admin/.npm/_logs/2020-01-22T19_13_27_378Z-debug.log
on windows I was able to resolve it by deleting the "node_modules" folder and reinstalling it but here in linux nothing works, deleting it or even reinstalling the dependencies.
Below is the contents of the error log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'serve' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'preserve', 'serve', 'postserve' ]
5 info lifecycle [email protected]~preserve: [email protected]
6 info lifecycle [email protected]~serve: [email protected]
7 verbose lifecycle [email protected]~serve: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~serve: PATH: /usr/share/npm/node_modules/npm-lifecycle/node-gyp-bin:/media/veracrypt1/themeforest-LSerfC0M-skote-vuejs-admin-dashboard-template/Admin/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
9 verbose lifecycle [email protected]~serve: CWD: /media/veracrypt1/themeforest-LSerfC0M-skote-vuejs-admin-dashboard-template/Admin
10 silly lifecycle [email protected]~serve: Args: [ '-c', 'vue-cli-service serve' ]
11 info lifecycle [email protected]~serve: Failed to exec serve script
12 verbose stack Error: [email protected] serve: `vue-cli-service serve`
12 verbose stack spawn ENOENT
12 verbose stack at ChildProcess.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
12 verbose stack at ChildProcess.emit (events.js:198:13)
12 verbose stack at maybeClose (internal/child_process.js:982:16)
12 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
13 verbose pkgid [email protected]
14 verbose cwd /media/veracrypt1/themeforest-LSerfC0M-skote-vuejs-admin-dashboard-template/Admin
15 verbose Linux 5.3.0-kali2-amd64
16 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "serve"
17 verbose node v10.17.0
18 verbose npm v6.13.4
19 error code ELIFECYCLE
20 error syscall spawn
21 error file sh
22 error errno ENOENT
23 error [email protected] serve: `vue-cli-service serve`
23 error spawn ENOENT
24 error Failed at the [email protected] serve script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]
Solution 1:[1]
Run:
npm i @vue/cli-service
That's because your dependence is not installed.
Solution 2:[2]
Removing node_modules
folder along with package-lock.json
file and running fresh npm install worked for me.
rm -rf node_modules package-lock.json && npm install
(Found solution here: https://github.com/vuejs/vue-cli/issues/2404#issuecomment-443397971)
NB
In case if moving to different/new OS environment - might also be that no vue-cli is installed, then install vue-cli as per instructions in the official guide.
Solution 3:[3]
Make sure to npm install
after npm i @vue/cli
, especially if you have Typescript.
There may be additional Typescript libraries necessary after installing @vue/cli
.
Solution 4:[4]
Try this:
- uninstall vue/cli with
npm uninstall -g @vue/cli
- install vue/cli again with
npm install -g @vue/cli
(you may also try it with sudo, likesudo npm install -g @vue/cli
) vue
Solution 5:[5]
Probably you have a problem with your babel.config.js file. Open it and chek out the path! In my case, the path was wrong! This will solve your problem for 90%.
At first it was...
module.exports = {
presets: [
'@vue/cli-plugins-babel/preset'
]
}
And, I found my mistake in PLUGINS and changed it as you see below. It woked perfectly! It should be PLUGIN not PLUGINS. I think this mistake happened when I used refactor(rename). In your case names can be different but if you find it. You will solve the problem!
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Mickael B. |
Solution 2 | ego |
Solution 3 | 21rw |
Solution 4 | |
Solution 5 | Jeremy Caney |