从github上面下载了一个项目,在本地执行
但是一直出现这样的错误
vue-cli-service 不是内部命令
> vue-cli-service serve
'vue-cli-service' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ofd.js@0.2.6 serve: `vue-cli-service serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ofd.js@0.2.6 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! C:\Users\lxn\AppData\Roaming\npm-cache\_logs\2021-01-11T03_45_19_333Z-debug.log
我以为环境变量的问题
vue的项目,我的电脑之前安装过vue
C:\Users\lxn>vue
Usage: vue <command> [options]
Options:
-V, --version output the version number
-h, --help output usage information
Commands:
init generate a new project from a template
list list available official templates
build prototype a new project
create (for v3 warning only)
help [cmd] display help for [cmd]
C:\Users\lxn>
项目的结构图如下:
原来十我一直没有很好的理解报错信息
WARN Local package.json exists, but node_modules missing, did you mean to install?
很明显是缺少node_modules
那么如何如何解决
package.json 中包含了运行项目需要的module
我们需要把这些依赖文件下载下来
vue-cli-service 这个命令这些依赖的包里面,而不是在环境变量里面的配置
如何下载
打开命令行 cmd
cd 到项目的package.json所在的文件目录
执行cnpm install
下载了相关的文件执行,再次运行项目
cnpm install 会寻找该目录下面的package.json 文件,并且下载文件中的依赖文件
如果你的cnpm 无法使用 可以使用npm install 这个在国内速度会慢一点
希望对你有所帮助