npm打包项目报错:npm ERR! A complete log of this run can be found in:npm ERR! C:\Users\AppData\Roa...

今天用npm打包项目的时候,用 "npm run build" 打包发生以下错误:

npm ERR!  missing script: build

npm ERR!  A complete log of this run can be found in:
npm ERR!   C:\Users\AppData\Roaming\npm-cache\_logs\2022-09-16T08_06_52_296Z-debug.log

第一个 npm ERR! 是因为缺少脚本:构建

第二个 npm ERR! 是因为此运行的日志可以再以下位置找到:

npm ERR!   C:\Users\AppData\Roaming\npm-cache\_logs\2022-09-16T08_06_52_296Z-debug.log

解决办法:

查看 package.json 中 scripts下打包命令 vue-cli-service build 是什么?我的如下:

 "scripts": {

    "dev": "vue-cli-service serve",

    "build:prod": "vue-cli-service build",

    "build:stage": "vue-cli-service build --mode staging",

    "preview": "node build/index.js --preview",

    "lint": "eslint --ext .js,.vue src",

    "test:unit": "jest --clearCache && vue-cli-service test:unit",

    "test:ci": "npm run lint && npm run test:unit",

    "svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml"

  },

我的打包命令是 build:prod ,因此使用 npm run build:prod,则打包成功。

 如果没有打包命令,则需要自己手动添加打包命令。

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
回答: 根据提供的引用内容,这是一个关于npm运行错误的问题。根据引用\[1\]和引用\[2\]的描述,这个错误可能是由于文件已经存在而导致的。解决方案可以尝试删除已存在的文件,然后再次运行npm命令。另外,根据引用\[3\]的描述,还可能是由于文件路径设置不正确导致的错误。可以检查文件路径是否正确设置。如果问题仍然存在,可以查看完整的日志文件以获取更多详细信息。 #### 引用[.reference_title] - *1* [npm打包项目报错npm ERR... A complete log of this run can be found in:npm ERR! C:\Users\AppData\Roa...](https://blog.csdn.net/qq_48639265/article/details/126892733)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [A complete log of this run can be found in: npm ERR! C:\Users\pc\AppData\Roaming\npm-cache\_logs](https://blog.csdn.net/weixin_45890764/article/details/113065073)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [ A complete log of this run can be found in: npm ERR! C:\Users\hp\AppData\Roaming\npm](https://blog.csdn.net/qq_50376293/article/details/120510274)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值