Reputation: 81
I am building a server and a client nwjs app, but I can't open both at the same time. I wonder if there is any way to do this. I run npm run dev
on both of my opened VS Code but when I run this command on the second app it just won't open at all (doesn't matter which one is the second app I would like to run). I tried to build the client app and run it and after it run the server app but it's the same, the second app won't start.
This is my package.json file in both app, I don't know if this helps at all. Only the name is different in the apps (nwjs_client and nwjs_server)
{
"name": "nwjs_server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "nw src/",
"prod": "nwbuild --platforms win32,win64,osx64,linux32,linux64 --buildDir dist/ src/"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"nw": "^0.49.1"
}
}
I'm willing to accept any answers, I don't know if it is even possible to run 2 different nwjs apps.
Upvotes: 1
Views: 426
Reputation: 2012
I'm confused by what you are trying to do.
index.html
, it loads displays a page from a local webserver:
server.js
that spins up a local web server on a specific port (like 4263
or something not super common).express
) make sure it is a dependency
and not a devDependency
."main"
in the package.json
to "http://localhost:4263
using the same port as the server"node-main"
to "server.js"
, this will run in the node context before your window is displayed when starting the app."node-remote"
to "http://localhost:4263"
using the same port also. This will allow Node commands to run on that URL when loaded in NW.js.npm install --save-dev concurrently wait-on
. This will install two devDeps"start": "concurrently \"npm run serve\" \"wait-on http://localhost:4263 && nw .\""
npm run serve
command, which presumably spins up a local webserver for development, if using something like webpack, this could take a minute. Then it waits until localhost:4263
actually returns a response. Then it launches NW.jsconcurrently will also let you run any two (or more) commands at the same time.
Upvotes: 0