npm ERR missing script: server npm ERR npm ERR Did you mean this? npm ERR serve npm ERR A

博主在尝试使用npm run server时遇到missingscript错误,通过逐步排查和npminstall解决。文章详细介绍了如何修复npm missingscript:server问题并确保依赖正确安装。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

npm ERR! missing script: server npm ERR! npm ERR! Did you mean this? npm ERR! serve npm ERR! A complete log of this run can be found in:

遇到的bug是

npm ERR! missing script: server npm ERR! npm ERR! Did you mean this? npm ERR!     serve  npm ERR! A complete log of this run can be found in:

因为

npm  run server

看了很多博客还是没解决

于是我用了以下的办法解决

npm install

我的pack

{
  "name": "vueblog-vue",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",              
    "build": "vue-cli-service build"
  },
  "dependencies": {
    "axios": "^0.19.2",
    "core-js": "^3.6.4",
    "element-ui": "^2.13.1",
    "github-markdown-css": "^5.1.0",
    "markdown-it": "^11.0.0",
    "mavon-editor": "^2.9.0",
    "vue": "^2.6.11",
    "vue-router": "^3.1.6",
    "vuex": "^3.1.3"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.3.0",
    "@vue/cli-plugin-router": "~4.3.0",
    "@vue/cli-plugin-vuex": "~4.3.0",
    "@vue/cli-service": "~4.3.0",
    "vue-template-compiler": "^2.6.11"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead"
  ]
}

将 serve 和 build的后面那些下载一次

npm vue-cli-service serve
npm vue-cli-service build

然后再执行

npm run serve

如果报错误

 ERROR  Failed to compile with 1 errors                                                                     下午10:58:58

This dependency was not found:

* github-markdown-css in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modul
es/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/BlogDetail.vue?vue&t
ype=script&lang=js&

To install it, you can run: npm install --save github-markdown-css

跟着提示

再运行

npm install --save github-markdown-css

再运行

npm run serve
### 解决 `npm missing script: server` 错误 当遇到 `npm missing script: server` 的错误提示时,这通常意味着在项目的 `package.json` 文件中未找到名为 `server` 的脚本。为了修正这个问题,有几种方法可以选择。 #### 方法一:添加 `server` 脚本到 `package.json` 如果确实需要使用 `server` 这个命令,则可以在 `package.json` 中的 `"scripts"` 字段下增加相应的条目: ```json { "name": "your-project", ... "scripts": { "serve": "vue-cli-service serve", // 如果是Vue CLI项目 "server": "node ./bin/www" // 或者其他启动服务器的方式 } } ``` 这样就可以通过执行 `npm run server` 来启动服务[^1]。 #### 方法二:使用已有的 `serve` 命令代替 `server` 对于许多前端框架来说,默认情况下已经存在了一个叫做 `serve` 的命令用于开发环境下的快速预览应用。比如,在 Vue CLI 创建的应用里,可以通过下面这条指令来启动本地的服务: ```bash npm run serve ``` 需要注意的是,修改完 `.eslintrc.js` 配置文件后也应当重新运行该命令以使新的 ESLint 设置生效。 另外,考虑到安全性问题,建议只安装来自可靠源的Node包,因为恶意软件可能会窃取系统的敏感数据并发送给远程服务器[^2]。 #### 使用替代方案 如果不是特别依赖于特定名称的脚本命令,那么可以直接调用实际负责启动HTTP(S)服务器的那个程序或工具链。例如,如果是Express应用程序的话,可能就是直接运行入口JS文件;而对于静态资源托管场景则可能是借助 http-server 等第三方库来进行部署测试。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值