从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: 这是由于没有node_modules模块导致的 那么如何如何解决 package.json 中包含了运行项目需要的module 我们需要把这些依赖文件下载下来npm i axios --save 发布到生产环境 这样安装是局部安装,会写进package.json文件中的dependencie dependencies:表示生产环境下的依赖管理 实际在项目中起作用,就可以使用 -s 来安装。 示例: "dependencies": { "animate.css": "^4.1.1", "ant-design-vue": "^1.7.8", "axios": "^0.24.0", "bin-code-editor": "^0.9.0", "core-js": "^3.6.5", "file-saver": "^2.0.5", "js-cookie": "^3.0.1", "linkdood-encrypt": "^1.0.1", "moment": "^2.29.4", "vue": "^2.6.11", "vue-progressbar": "^0.7.5", "vue-router": "^3.2.0", "vuex": "^3.4.0", "vuex-persistedstate": "^4.1.0" }, npm install axios --save-dev 这样安装是局部安装的,会写进package.json文件中的devDependiencies里 devDependiencie:表示开发环境下的依赖管理 如果安装的库是用来打包,解析代码的,比如webpack,babel,就可以用-d来安装 项目上线了,这些库就没用了 示例 "devDependencies": { "@vue/cli-plugin-babel": "~4.5.15", "@vue/cli-plugin-eslint": "~4.5.15", "@vue/cli-plugin-router": "~4.5.15", "@vue/cli-plugin-vuex": "~4.5.15", "@vue/cli-service": "~4.5.15", "@vue/eslint-config-standard": "^5.1.2", "babel-eslint": "^10.1.0", "eslint": "^6.8.0", "eslint-plugin-import": "^2.20.2", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^4.2.1", "eslint-plugin-standard": "^4.0.0", "eslint-plugin-vue": "^6.2.2", "less": "^3.0.4", "less-loader": "^5.0.0", "style-resources-loader": "^1.5.0", "vue-template-compiler": "^2.6.11" }, 删除 node_modules文件夹 打开命令行 cmd cd 到项目的package.json所在的文件目录 执行cnpm install 下载了相关的文件执行,再次运行项目 cnpm install 会寻找该目录下面的package.json 文件,并且下载文件中的依赖文件 如果你的cnpm 无法使用 可以使用npm install 这个在国内速度会慢一点 |
|