electron-builder打包+electron-updater在线更新的项目打包各种报错,求指教咋回事?

下面是我的package.js中的配置:

{
  "name": "**",
  "version": "2.0.0",
  "description": "**",
  "main": "main.js",
  "scripts": {
     "build": "electron-builder",
     "build:dir": "electron-builder --dir"
},
  "devDependencies": {
    "electron": "^8.1.1",
    "electron-builder": "^22.4.1",
    "electron-updater": "^4.2.5"
  },
  "build": {
    "productName":"***",
    "appId": "com.***",
    "copyright":"**",
    "directories": {
      "output": "build"
    },
    "asar": false,
    "nsis": {
      "oneClick": false,
      "allowElevation": true,
      "allowToChangeInstallationDirectory": true,
      "installerIcon": "clientLogo.ico",
      "uninstallerIcon": "clientLogo.ico",
      "installerHeaderIcon": "clientLogo.ico",
      "createDesktopShortcut": true,
      "createStartMenuShortcut": true,
      "shortcutName": "***",
      "include": "build/script/installer.nsh"
    },
    "publish": [
      {
        "provider": "generic",
        "url": "C:\\Users\\Shinelon\\Desktop\\*****\\myApp"
      }
    ],
    "files": [
      "dist/electron/**/*"
    ],
    "dmg": {
      "contents": [
        {
          "x": 410,
          "y": 150,
          "type": "link",
          "path": "/Applications"

        },
        {

          "x": 130,
          "y": 150,
          "type": "file"
        }
      ]
    },
    "win": {
      "icon": "clientLogo.ico",
      "target": [
        {
          "target": "nsis"
        }
      ]
    },
    "linux": {
      "icon": "build/icons"
    }

  }
}


下面是我的错误日志:

9 verbose lifecycle '项目'@2.0.0~build: CWD: C:\Users\Shinelon\Desktop\'项目'在线更新版本测试\'项目'(在线更新版本测试)

10 silly lifecycle '项目'@2.0.0~build: Args: [ '/d /s /c', 'electron-builder' ]

11 silly lifecycle '项目'@2.0.0~build: Returned: code: 1 signal: null

12 info lifecycle '项目'@2.0.0~build: Failed to exec build script

13 verbose stack Error: '项目'@2.0.0 build: `electron-builder`

13 verbose stack Exit status 1

13 verbose stack   at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)

13 verbose stack   at EventEmitter.emit (events.js:321:20)

13 verbose stack   at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.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 '项目'@2.0.0

15 verbose cwd C:\Users\Shinelon\Desktop\'项目'在线更新版本测试\'项目'(在线更新版本测试)

16 verbose Windows_NT 10.0.17134

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 '项目'@2.0.0 build: `electron-builder`

22 error Exit status 1

23 error Failed at the '项目'@2.0.0 build script.

23 error This is probably not a problem with npm. There is likely additional logging output above.

24 verbose exit [ 1, true ]


ps:再上面几条粘不开了





















































































































































可能是版本的问题

1. 卸载npm uninstall webpack-dev-server

然后 npm i -D webpack-dev-server@3.0.0


再 npm run dev 试试


2.重新安装一次,如果还是不可以的话,在把之前装的都清空


rm -rf node_modules

rm package-lock.json

npm cache clear --force

npm install


我想起来了我没有用webpack

第一步卸载就报404了


npm ERR! code E404

npm ERR! 404 Not Found - GET https://github.com/electron/electron-builder

npm ERR! 404

npm ERR! 404 'electron-builder@22.4.1' is not in the npm registry.

npm ERR! 404 You should bug the author to publish it (or use the name yourself!)

npm ERR! 404 It was specified as a dependency of '项目(在线更新版本测试)'

npm ERR! 404

npm ERR! 404 Note that you can also install from a

npm ERR! 404 tarball, folder, http url, or git url.


npm ERR! A complete log of this run can be found in:

npm ERR!   C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2020-03-16T07_49_59_479Z-debug.log