nw.js icon indicating copy to clipboard operation
nw.js copied to clipboard

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

Open suns-echoes opened this issue 10 years ago • 8 comments

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

PROJECT_ROOT
    ┣ 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" %*

suns-echoes avatar Apr 02 '16 17:04 suns-echoes

Nobody can resolve this issue? @rogerwang

fangsmile avatar Apr 11 '16 05:04 fangsmile

@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".

ghost avatar Apr 29 '16 06:04 ghost

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

fangsmile avatar May 09 '16 09:05 fangsmile

@rogerwang ???

fangsmile avatar Jun 17 '16 07:06 fangsmile

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:

PROJECT_ROOT
    ┣ 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.

suns-echoes avatar Jun 17 '16 07:06 suns-echoes

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

fangsmile avatar Jun 17 '16 07:06 fangsmile

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

Leprosy avatar Mar 23 '17 16:03 Leprosy

will add a command line flag to specify project root.

rogerwang avatar Mar 24 '17 00:03 rogerwang