question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

install-app-deps: Configuring yargs through package.json is deprecated

See original GitHub issue
  • Version: 20.39.0

  • Target: 4.0.8 on platform=win32 arch=x64

I have a few local native modules linked via file: in package.json.

> electron-builder install-app-deps

Configuring yargs through package.json is deprecated and will be removed in the next major release, please use the JS API instead.
Configuring yargs through package.json is deprecated and will be removed in the next major release, please use the JS API instead.
  • electron-builder version=20.39.0
  • loaded configuration file=package.json ("build" field)
  • rebuilding native production dependencies platform=win32 arch=x64

What are the yargs errors about?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:34
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
nathanlesagecommented, Mar 18, 2019

@ivancuric It’s just weirdly documented.

As it says in the API docs:

image

Raw Options refer to the CLI options and there you’ll find this:

image

So CLI equals API arguments, i.e. you’d have to pass the command line arguments into the package.jsons build-property and hope you place them at the right position in the tree.


Downside of this is obviously that you’d need several different scripts to pass data to the builder so that it does not always trigger a full chain-rebuild if you just want to drop a testing app into the release directory, so you’d have to do something like this to avoid this:

// Some script file, i.e. build.js
const builder = require('electron-builder')

// ... Some logic that builds up the build field, e.g.:
let options = {
  "win": {
    "target": [
      {
        "target": "nsis",
        "arch": [
          "x64",
          "ia32"
        ]
      }
    ]
  }

builder.build(options).then((sth) => {
  // I have literally no idea what would be passed
  // during a successful call, maybe just dump it
  // to the console
  console.log(sth)
}).catch((e) => {
  // Some error handling
  console.error(e)
})
4reactions
Faksprodcommented, Apr 3, 2019

Same problem here when I tried to run code containing in my package.json file from the CLI (Terminal) on MacOS Mojave (was working well 3 months ago before my yesterday Electron update).

  • Electron: 4.1.3
  • Electron-builder: 20.39.0

package.json

{
    "scripts": {
        "start": "electron .",
        "build": "electron-builder",
        "build-mac": "electron-builder --mac"
    },
    "build": {
        "appId": "com.myCompany.myApp",
        "productName": "myAppName",
        "copyright": "Copyright © 2019 myCompany",
        "mac":{
            "target":"mas",
            "type":"distribution",
            "provisioningProfile":"myApp.provisionprofile",
            "identity": "MyCompany (idNumber)",
        },
        "directories": {
            "output": "build"
        }
    }
}

When I try to run npm run build-mac it gives me this error message Configuring yargs through package.json is deprecated and will be removed in the next major release, please use the JS API instead.

Thanks to @nathanlesage I finally found the solution. It wasn’t really clear for me about where I should put the build.js file et how to execute it (I’m not a Node JS pro). If someone is in my case, here are more detailed steps:

  • Create a new JS file in the folder containing the package.json file.
  • You can give any name to this new JS file (eg: myCustomScript.js).
  • In this myCustomScript.js file you will use the electron-builder JS API to run your build instead of using the CLI command electron-builder --mac.
  • Put this script (from the electron-builder doc).
  • Change the targets property if needed and custom the config property.
  • In the config property you just have to copy paste the object contained in the “build” tree of your package.json. Then you can remove the “build” part from your package.json tree cause you don’t need here anymore.
  • Finally, to call and execute your myCustomScript.js you can add a line in the scripts property of your package.json like this:
"scripts": {
    "myCustomScript": "node myCustomScript.js"
}
  • Then you can call it from the Terminal like this npm run myCustomScript

So now, my files looks like below and it works like a charm!

package.json (new)

{
    "scripts": {
        "start": "electron .",
        "build": "electron-builder",
        "myCustomScript": "node myCustomScript.js"
    }
}

myCustomScript.js

"use strict";

const builder = require("electron-builder");
const Platform = builder.Platform;

builder.build({
    targets: Platform.MAC.createTarget(),
    config: {
        
        "directories": {
            "output": "build"
        },
        "appId": "com.myCompany.myApp",
        "productName": "myAppName",
        "copyright": "Copyright © 2019 myCompany",

        "mac":{
            "target":"mas",
            "type":"distribution",
            "provisioningProfile":"myApp.provisionprofile",
            "identity": "MyCompany (idNumber)"
        }
    }
})
.then(() => {
    // handle result
    console.log('Build OK!');
})
.catch((error) => {
    // handle error
    console.log(error);
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

Stuck when creating credentials - Yargs through package.json ...
Configuring yargs through package.json is deprecated and will be removed in the next major release, please use the JS API instead.
Read more >
Configuring yargs through package.json is deprecated and ...
Configuring yargs through package.json is deprecated and will be removed in the next major release, please use the JS API instead.
Read more >
Electron-builder NPM
Specify the build configuration in the package.json as follows: ... add script "postinstall": "electron-builder install-app-deps" to your package.json .
Read more >
electron-builder | Yarn - Package Manager
A complete solution to package and build a ready for distribution Electron app for MacOS, Windows and Linux with “auto update” support out...
Read more >
Error when using the sqlite3 module in electron - Super User
Configuring yargs through package.json is deprecated and will be removed in the next major release, please use the JS API instead.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found