npm run build时,我需要拿到生成的latest.yml文件,却未生成latest.yml文件?

发布于 2022-09-12 01:05:43 字数 8618 浏览 6 评论 0

问题描述

执行npm run build时,我需要拿到生成的latest.yml文件,打包的结果是,正常生成exe文件,却未生成latest.yml文件,不知是否跟打包到最后时出现的下面错误相关
OKAY take it away electron-builder

• electron-builder version=21.2.0 os=10.0.10240
• loaded configuration file=package.json ("build" field)
• writing effective config file=buildbuilder-effective-config.yaml
• packaging platform=win32 arch=x64 electron=7.1.9 appOutDir=buildwin-unpacked
• asar using is disabled — it is strongly not recommended solution=enable asar and use asarUnpack to unpack files that must be externally avail
able
• building target=zip arch=x64 file=build文书通-0.0.1-win.zip
• building target=nsis file=build文书通 Setup 0.0.1.exe archs=x64 oneClick=true perMachine=false
⨯ [object Object]
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-project@0.0.1 build: node .electron-vue/build.js && electron-builder
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-project@0.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersAdministratorAppDataRoamingnpm-cache_logs2020-02-19T02_37_35_328Z-debug.log

问题出现的环境背景及自己尝试过哪些方法

搞了很久,一直搞不明白怎么回事,卸载重装过所有的依赖,而且打包后生成的exe文件是可以正常使用的。但我需要使用electron-builder实现客户端的自动更新,需要npm run build时生成latest.yml文件,此文件无法生成,不知道是否跟上述的报错相关。

相关代码

// 请把代码文本粘贴到下方(请勿用图片代替代码)
这是packge.json文件
{

"name": "my-project",
"version": "0.0.1",
"author": "zhengweixiong <zwx163_2015@163.com>",
"description": "An electron-vue project",
"license": "null",
"private": true,
"main": "./dist/electron/main.js",
"scripts": {
    "build": "node .electron-vue/build.js && electron-builder",
    "build:dir": "node .electron-vue/build.js && electron-builder --dir",
    "build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js",
    "build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js",
    "dev": "node .electron-vue/dev-runner.js",
    "pack": "npm run pack:main && npm run pack:renderer",
    "pack:main": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.main.config.js",
    "pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js",
    "postinstall": ""
},
"build": {
    "asar": false,
    "extraResources": [
        "__static"
    ],
    "productName": "test",
    "appId": "com.example.yourapp",
    "directories": {
        "output": "build"
    },
    "publish": [{
        "provider": "generic",
        "url": "",
        "channel": "latest"
    }],
    "files": [
        "dist/electron/**/*"
    ],
    "nsis": {
        "oneClick": true,
        "perMachine": true,
        "allowElevation": true,
        "allowToChangeInstallationDirectory": true,
        "createDesktopShortcut": true,
        "runAfterFinish": true,
        "installerIcon": "build/icons/icon.ico",
        "uninstallerIcon": "build/icons/icon.ico"
    },
    "dmg": {
        "contents": [{
                "x": 410,
                "y": 150,
                "type": "link",
                "path": "/Applications"
            },
            {
                "x": 130,
                "y": 150,
                "type": "file"
            }
        ]
    },
    "mac": {
        "icon": "build/icons/icon.icns"
    },
    "win": {
        "icon": "build/icons/icon.ico",
        "publish": [{
            "provider": "generic",
            "url": "",
            "channel": "latest"
        }]
    },
    "linux": {
        "icon": "build/icons"
    }
},
"dependencies": {
    "@kiyoaki_w/vue-context": "^1.0.3",
    "axios": "^0.18.0",
    "e-vue-contextmenu": "^0.1.3",
    "electron-updater": "^4.2.2",
    "element-ui": "^2.11.1",
    "iview": "^3.4.2",
    "jquery": "^3.4.1",
    "js-base64": "^2.5.1",
    "js-md5": "^0.7.3",
    "picture-preview": "^1.0.1",
    "tus-js-client": "^1.8.0",
    "v-viewer": "^1.5.1",
    "vue": "^2.5.16",
    "vue-context": "^5.0.0",
    "vue-electron": "^1.0.6",
    "vue-lazyload": "^1.3.3",
    "vue-router": "^3.0.1",
    "vue-socket.io": "^3.0.7",
    "vuex": "^3.0.1",
    "vuex-electron": "^1.0.0",
    "web-mqtt-client": "^1.3.1"
},
"devDependencies": {
    "ajv": "^6.5.0",
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.4",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-stage-0": "^6.24.1",
    "babel-register": "^6.26.0",
    "babili-webpack-plugin": "^0.1.2",
    "cfonts": "^2.1.2",
    "chalk": "^2.4.1",
    "copy-webpack-plugin": "^4.5.1",
    "cross-env": "^5.1.6",
    "css-loader": "^0.28.11",
    "del": "^3.0.0",
    "devtron": "^1.4.0",
    "electron": "^7.1.9",
    "electron-builder": "^21.2.0",
    "electron-debug": "^1.5.0",
    "electron-devtools-installer": "^2.2.4",
    "file-loader": "^1.1.11",
    "html-webpack-plugin": "^3.2.0",
    "mini-css-extract-plugin": "0.4.0",
    "multispinner": "^0.2.1",
    "node-loader": "^0.6.0",
    "node-sass": "^4.9.2",
    "rightmenu": "^1.1.0",
    "sass-loader": "^7.0.3",
    "style-loader": "^0.21.0",
    "url-loader": "^1.0.1",
    "vue-html-loader": "^1.2.4",
    "vue-loader": "^15.2.4",
    "vue-style-loader": "^4.1.0",
    "vue-template-compiler": "^2.5.16",
    "webpack": "^4.15.1",
    "webpack-cli": "^3.0.8",
    "webpack-dev-server": "^3.1.4",
    "webpack-hot-middleware": "^2.22.2",
    "webpack-merge": "^4.1.3"
}

}

这是日志
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'build'
1 verbose cli ]
2 info using npm@6.13.4
3 info using node@v12.16.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle my-project@0.0.1~prebuild: my-project@0.0.1
6 info lifecycle my-project@0.0.1~build: my-project@0.0.1
7 verbose lifecycle my-project@0.0.1~build: unsafe-perm in lifecycle true
8 verbose lifecycle my-project@0.0.1~build: PATH: C:Program Filesnodejsnode_modulesnpmnode_modulesnpm-lifecyclenode-gyp-bin;E:工作electronmy-projectnode_modules.bin;C:Program FilesGitmingw64bin;C:Program FilesGitusrbin;C:UsersAdministratorbin;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:Program FilesGitcmd;C:Program FilesMongoDBServer3.4bin;C:Python27;D:Microsoft VS Codebin;C:Program Filesnodejs;C:Program FilesJavajdk1.8.0_91bin;C:Androidsdkplatform-tools;C:Androidsdktools;C:Python27;C:Python27Scripts;C:UsersAdministratorAppDataRoamingnpm
9 verbose lifecycle my-project@0.0.1~build: CWD: E:工作electronmy-project
10 silly lifecycle my-project@0.0.1~build: Args: [ '/d /s /c', 'node .electron-vue/build.js && electron-builder' ]
11 silly lifecycle my-project@0.0.1~build: Returned: code: 1 signal: null
12 info lifecycle my-project@0.0.1~build: Failed to exec build script
13 verbose stack Error: my-project@0.0.1 build: node .electron-vue/build.js && electron-builder
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:Program Filesnodejsnode_modulesnpmnode_modulesnpm-lifecycleindex.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:321:20)
13 verbose stack at ChildProcess.<anonymous> (C:Program Filesnodejsnode_modulesnpmnode_modulesnpm-lifecyclelibspawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:321:20)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid my-project@0.0.1
15 verbose cwd E:工作electronmy-project
16 verbose Windows_NT 10.0.10240
17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "build"
18 verbose node v12.16.0
19 verbose npm v6.13.4
20 error code ELIFECYCLE
21 error errno 1
22 error my-project@0.0.1 build: node .electron-vue/build.js && electron-builder
22 error Exit status 1
23 error Failed at the my-project@0.0.1 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

你期待的结果是什么?实际看到的错误信息又是什么?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文