nw.js: index.html in a parent folder

Viewed 140

The organization of my project's folder is currently as follows:

Root folder
| media folders
| js folder
| index.html
| NW folder

The package.json NW reads is inside the NW folder, which also contains everything in the SDK archive, but whatever I write doesn't seem to point at index.html. I tried both "main": "./../index.html" and "main": "../index.html", but neither of them works.

What's the correct way to point at index.html in the parent folder? Thanks in advance.

2 Answers

You shouldn't be putting package.json in the NW folder. Put package.json next to index.html (in the root folder) and run NW.js from that folder. Your main would then point to "./index.html".

cd /your/root/folder
mv "NW folder/package.json" .
"./NW folder/nw" .

I would recommend putting all of your project files into a package.nw folder with the package.json inside that. When you open nw.exe it will look for a package.nw folder next to it, and then try to run the app inside it.

YourProject/
  ├── package.nw/
  │   ├── media/
  │   ├── js/
  │   ├── css/
  │   ├── index.html
  │   └── package.json
  ├── locales/
  ├── swiftshader/
  ├── nw.dll
  ├── nw.exe
  └── all the other NW.js files...

Then you can just rename nw.exe to MyApp.exe, customize its icon with ResourceHacker, zip up the YourProject folder and send it to a buddy to try out. Then all they have to do is "unzip/double-click".

Related