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.

Unable to open a file as argument with an NWjs app on Windows

See original GitHub issue

Affected OS and NW.js version

Windows 7, 8 Any NW.js version since v0.10.3 (september 2014)

Issue

Unable to make an NW.js application that open files on Windows (or to pass a filepath as first argument).

The official specification (Handling files and arguments) is outdated or does not work as described in Windows. No newer specification discuss this functionality. This issue has already been reported many times #2416 #4951 #2525 Since then no fix has been given, despite it’s an essential function for any desktop application.

How to reproduce

Create two files named “package.json” and “app.html” inside a folder named “app.nw” :

  • package.json
{
  "name": "Test",
  "main": "app.html",
  "version": "0.1.0",
  "description": "Test App"
}
  • app.html
<html>
<body>
<script>
    /* As described on https://github.com/nwjs/nw.js/wiki/Handling-files-and-arguments */
    var gui = require('nw.gui');
    document.write(gui.App.argv);
    gui.App.on('open', function(cmdline) {
      document.write('command line: ' + cmdline);
    });
</script>
</body>
</html>

Then package your app using for instance nwjs-builder : nwb nwbuild app.nw

Finally, right-click any file on your computer, then click “Open with…” and select the previously build Test.exe Result : nothing happens (app crash on loading).

You can also try the command line : .\Test.exe credits.html The app will crash on loading if the file “credits.html” exists, but works well otherwise.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
rogerwangcommented, Apr 12, 2017

This is fixed in git and will be available in the next nightly build.

0reactions
octachromecommented, May 4, 2017

This fixes the problem I had. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Command Line Options - NW.js Documentation
When a user uses your app to open a file under command line, ... line argument is the filename of .js file on...
Read more >
How to open file in NWJS or Electron app? - Stack Overflow
I just explained this, you need to register your application to handle the file types you want it to open, then you will...
Read more >
nwjs/nw.js - Gitter
i cant open .js associate file to my program this crash programm ... onto the nw.exe file, it will then launch NW.js and...
Read more >
Run/Debug Configuration: NW.js | PhpStorm Documentation
In this field, specify the application to launch. You can select an entire directory that contains a package.json file or the same directory ......
Read more >
Window - NW.js Documentation - Read the Docs
Every Window is an instance of the EventEmitter class, and you're able to use ... Window.open('https://github.com/nwjs/nw.js', {}, function(new_win) { // do ...
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