Nw.js: Relative path to HTML file no longer works (package.json - main)

Created on 2 Apr 2016  Â·  8Comments  Â·  Source: nwjs/nw.js

Hello.

First things first:
NWJS: 13.0 x64 DEV and 13.2 x64 DEV
OS: Win 10 Home x64

Relative path to main HTML file cannot be used anymore. It was working fine on 0.12.3 but now I must do one of two things:

  1. put main HTML together with package.json
  2. set absolute path to main HTML in package.json->main (not an option for me).

If I try to use relative path, then I get:

Nie znaleziono pliku (File not found)

Mógł zostać przeniesiony lub usunięty. (It could be moved or deleted.)
ERR_FILE_NOT_FOUND

I believe it is not intended behavior because I haven't found this in documentation.

Files structure

    ┣ NWJS
    ┃ ┗ package.json
    ┣ start.html
    â”— start.bat

package.json

{

    "main": "../start.html",

    "name": "AppName",
    "description": "",
    "version": "1",

    "nodejs": true,

    "window": {
        "title": "app title",
        "icon": "",
        "frame": true,
        "width": 920,
        "height": 520,
        "position": "center"
    },

    "webkit": {
        "plugin": false
    },

    "chromium-args": "--data-path='NWJS/Storage' --user-data-dir='NWJS/User data'"

}

start.bat

@echo off
cd /d %~dp0
start "" "..\..\bin\0.13.2 SDK\x64\nw.exe" "%cd%/NWJS" %*
P2 feature-request nw13

Most helpful comment

will add a command line flag to specify project root.

All 8 comments

Nobody can resolve this issue? @rogerwang

@liufangfang
A solution for now is to use symlinks. In your folder with nw.exe create a symlink named "package.nw" which points to PROJECT_ROOT folder. In the PROJECT_ROOT folder you can put a "package.json" file and change "main" to "start.html".

It should be a bug. I expect the authority can fix it. I can only wait, @rogerwang

@rogerwang ???

After this issue I have changed my approach. Maybe it will be useful for someone. I still don't like to place package.json in root folder but haven't yet try to move it deeper in newest release.

File structure:

    ┣ cache/
    ┣ package.json
    ┣ index.html
    â”— run.bat

run.bat
Batch file I use to start the application. It can be converted to exe with ease.

@echo off
cd /d %~dp0
start /b "" ..\..\bin\RUN_LATEST_SDK.bat "%cd%" %*
exit

RUN_LATEST_SDK.bat
This batch is single place that redirects to path of for the latest NWJS version.

I will publish it's content when I'll be back home.

If I change my directory structure, I will do a big change.

I'm having the same issue...is this going to be solved in some way?

will add a command line flag to specify project root.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rumax picture rumax  Â·  4Comments

niutech picture niutech  Â·  4Comments

Asp3ctus picture Asp3ctus  Â·  4Comments

hooker99 picture hooker99  Â·  4Comments

nawazishali picture nawazishali  Â·  3Comments