Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify manifest file explicitly #5990

Open
sebamarynissen opened this issue Jun 27, 2017 · 3 comments
Open

Specify manifest file explicitly #5990

sebamarynissen opened this issue Jun 27, 2017 · 3 comments

Comments

@sebamarynissen
Copy link

Hi,

I'm having the following problem. I'm developing a module for node.js which of course has it's proper package.json file with a "main" field, which is in my case

{
  "main": "lib/index.js"
}

However, for some testing reasons, I want to run nw.js as well in this folder. The problem though is that I cannot simply change the "main" field to for example

{
  "main": "nw/index.html"
}

as this would break all my .js files which do something like

var mylib = require('..');

where ".." resolves to the main directory of my module.
I tried to solve this by creating a separate package.json file for nw.js and put it in a sub-folder of my module and subsequently running nw from that sub-folder. This doesn't solve the issue though because as such I'm unable to refer any files in the parent directory, which is what I need:

<!-- ".." won't work when nw is run from within the subfolder. -->
<script type="text/javascript" src="../lib/index.js"></script>

I tried searching for a way to specify the manifest file explicitly so that nw.js reads in the required data from there, and not from the default package.json. This would allow me to create a new manifest file, called for example package-nw.json that would live happily next to the node module's package.json file, and then launch nw.js from the main directory as (something like)

nw . --manifest=package-nw.json

I found that a command line --nwapp already exists, but that doesn't seem to allow me to specify my manifest file, only the app directory. I need to specify my manifest file instead.

I know that I could solve this by creating a dedicated package.json file in a build process, but I just want to play around with nw.js during development of my node module. I don't need it for production. Therefore, in my opinion, a feature to specify the manifest file explicitly would be useful.

I'm running nw.js 0.23.4 on Windows 7, but this isn't going to matter too much I guess as the problem is pretty general.

@nickverlinden
Copy link

I had exactly the same issue yesterday, but I worked around this by doing the reverse you did.
I created a subfolder containing all node.js code called "bin", then in that bin folder is a package.json for node.js. The node_modules folder remains in the root. Then in the project root folder there is an index.html, package.json (contain all node.js info, but the main tag is for nw.js) and a run.js file. This run.js file just has a line "require("bin/index.js"). This allows you to start the app from node using the following command: node ./run.js. If you then set the execute flag for the run.js file and add a shell shim on the first line of run.js (), then you can even do this on the command: "./run.js". Not the ideal world scenario, but works for me.

@aprilandjan
Copy link

Need this too

@BrettFraley
Copy link

2024: Found this issue today. I'm working around it. Is there a flag that for this that I haven't found?
eg: nw ./src/index.html --manifest="path-to-package.json"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants