Nativefier: --file-download-options doenst work on windows

Created on 11 Apr 2018  路  8Comments  路  Source: jiahaog/nativefier

Hello,

I can't create an new app on windows. OSX works fine.
NodeJS Version: 8.11.1
nativefier Version: 7.6.1

I am getting the message:

C:\Users\admin\AppData\Roaming\npm\node_modules\nativefier\lib\cli.js:19
}
 ^
SyntaxError: Unexpected token ' in JSON at position 0
    at JSON.parse (<anonymous>)
    at parseJson (C:\Users\admin\AppData\Roaming\npm\node_modules\nativefier\lib\cli.js:19:2)
    at Command.<anonymous> (C:\Users\admin\AppData\Roaming\npm\node_modules\nativefier\node_modules\commander\index.js:412:13)
    at emitOne (events.js:116:13)
    at Command.emit (events.js:211:7)
    at Command.parseOptions (C:\Users\admin\AppData\Roaming\npm\node_modules\nativefier\node_modules\commander\index.js:726:14)
    at Command.parse (C:\Users\admin\AppData\Roaming\npm\node_modules\nativefier\node_modules\commander\index.js:471:21)
    at Object.<anonymous> (C:\Users\admin\AppData\Roaming\npm\node_modules\nativefier\lib\cli.js:49:4644)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Function.Module.runMain (module.js:684:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3`
need-info

Most helpful comment

I solved it with backslash:
--file-download-options "{\"saveAs\": true}"

All 8 comments

@basu90 thanks for the feedback. Two questions for you:

  1. Please post the full nativefier command you used to build your app.
  2. Can you open C:\Users\admin\AppData\Roaming\npm\node_modules\nativefier\lib\cli.js in Notepad (or any other editor) and paste here the contents of lines 10 to 30?

Thanks 馃檪.

no problem:
command call:
nativefier --icon "icon.ico" --platform "windows" --counter --name "XXX" --width "1920" --height "1080" --min-width "1280" --min-height "800" --app-copyright "XXX GmbH" --app-version "1.00" --build-Version "1.00" --ignore-certificate --single-instance --user-agent "nativefier V1.00" --insecure --disable-context-menu --file-download-options '{"saveAs": true}' "https://test.com"

line 10-30 from cli.js

var _index = require('./index');

var _index2 = _interopRequireDefault(_index);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var dns = require('dns');
var packageJson = require('./../package');
var log = require('loglevel');

function collect(val, memo) {
  memo.push(val);
  return memo;
}

function parseJson(val) {
  if (!val) return {};
  return JSON.parse(val);
}

@basu90 hm, your command works for me.

Can you edit C:\Users\admin\AppData\Roaming\npm\node_modules\nativefier\lib\cli.js and, in the parseJson function, below if (!val) return {};, add this: console.log('========== trying to JSON.parse', val);

The updated function will look like:

function parseJson(val) {
  if (!val) return {};
  console.log('========== trying to JSON.parse "', val, '"');
  return JSON.parse(val);
}

Then re-run your nativefier command: on which value did JSON.parse choke on?

Hi,
i will try it later. I thinks its stock on the new --file-download-options '{"saveAs": true}' flag. Its working good without it.

Alright. Maybe you passed a single quote in here, making it invalid JSON. Closing, feel free to chime in if the problem comes back, and I'll re-open 馃檪.

I solved it with backslash:
--file-download-options "{\"saveAs\": true}"

@basu90 yup 馃檪. Or you can have double quotes in single quotes: --file-download-options '{"saveAs": true}'

--file-download-options "{\"saveAs\": true}"

Thanks @basu90 !

--file-download-options '{"saveAs": true}'

Does not work for me either when using single outer quotes.

Windows 10, nativefier 7.6.12

Was this page helpful?
0 / 5 - 0 ratings