从gitee克隆VUE项目到本地后,不能直接运行,需要进行npm install安装node_modules文件夹里面的内容,因为在git上传的时候,一般都会过滤到node_modules中的依赖文件。
安装依赖以后,启动通过npm run serve启动项目出错。
PS C:\Users\Administrator\Desktop\VueStudy> npm run serve
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\Administrator\Desktop\VueStudy\package.json
npm ERR! errno -4058
npm ERR! enoent Could not read package.json: Error: ENOENT: no such file or directory, open 'C:\Users\Administrator\Desktop\VueStudy\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoentnpm ERR! Log files were not written due to an error writing to the directory: D:\node\node_cache\_logs
npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
解决办法:
因为我的项目里面有2层文件夹,启动项目的时候,没有在package.json的同级目录启动,所以出现了上面的错误,将启动目录切换到 package.json的同级目录,在run就成功了。