sh: vue-cli-service: command not found npm ERR! code ELIFECYCLE npm ERR! syscall spawn

下载完项目使用npm run serve运行,

报错

sh: vue-cli-service: command 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 WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/guojingrui/.npm/_logs/2021-12-14T12_14_14_856Z-debug.log

原因

缺少node_modules的文件

解决方法

执行以下命令,就会下载node_modules文件.等待安装完毕,再次运行就没问题了

npm install

执行结果

npm install
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!

> [email protected] install /Users/guojingrui/Desktop/demo/gjr/vue/vue_test/node_modules/watchpack-chokidar2/node_modules/fsevents
> node install.js

  SOLINK_MODULE(target) Release/.node
  CXX(target) Release/obj.target/fse/fsevents.o
  SOLINK_MODULE(target) Release/fse.node

> [email protected] install /Users/guojingrui/Desktop/demo/gjr/vue/vue_test/node_modules/webpack-dev-server/node_modules/fsevents
> node install.js

  SOLINK_MODULE(target) Release/.node
  CXX(target) Release/obj.target/fse/fsevents.o
  SOLINK_MODULE(target) Release/fse.node

> [email protected] install /Users/guojingrui/Desktop/demo/gjr/vue/vue_test/node_modules/yorkie
> node bin/install.js

setting up Git hooks
done


> [email protected] postinstall /Users/guojingrui/Desktop/demo/gjr/vue/vue_test/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js:
> https://opencollective.com/core-js 
> https://patreon.com/zloirock 
> https://paypal.me/zloirock 
> bitcoin: bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)


> [email protected] postinstall /Users/guojingrui/Desktop/demo/gjr/vue/vue_test/node_modules/ejs
> node ./postinstall.js

Thank you for installing EJS: built with the Jake JavaScript build tool (https://jakejs.com/)

added 1336 packages from 690 contributors and audited 1336 packages in 89.698s

90 packages are looking for funding
  run `npm fund` for details

found 14 vulnerabilities (11 moderate, 3 high)
  run `npm audit fix` to fix them, or `npm audit` for details

你可能感兴趣的:(sh: vue-cli-service: command not found npm ERR! code ELIFECYCLE npm ERR! syscall spawn)