-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
'Main is required': Local package.json clobbers packaged file on OSX. #1503
Comments
I'd venture to guess this turns up now and then and then disappears again because using a package.json to install npm packages it pretty common, but if you move your files around it 'suddenly works'. |
I just updated NW today vs a version I installed a few weeks ago and now I'm getting this error when I run
Didn't do anything to the project other than reinstall some of the libs. Now the app won't run. Here's my directory tree, from the root of the project:
As you can see I have 2 package.json files, one for installing node modules at the project level, the other is the manifest for the application itself. The package.json file contained within the app directory contains the following:
The package.json file in the root does not have a main property, but even when I attempt to add one (pointing to |
Also, here's the package.json for the root of the project:
|
same problem. |
FYI, here are the versions for the libs I'm using on the computer for which this fails:
To compare, my home machine can run the app just fine, even after rebasing my most recent changes and it has the following versions:
|
@rogerwang Do you have any input on this issue? Would love some guidance please. |
@commadelimited For what it's worth, I resolved this myself by bundling all the project assets into the distributable osx application folder (Content/Resources) in the node-webkit.app as a build step. (the code may be slightly difficult to follow, but the details are here https://github.com/shadowmint/ruffx/blob/master/src/ruffx/webkit/__init__.py --> basically, every build, create a new copy of node-webkit.app, a new zip file of the app/ folder, and copy the zip file into node-webkit.zip/Contents/Resources) You can then launch it via: open build/my.app ...but it is a slow and frustrating way to interact with node-webkit. I ended up doing dev on a windows machine and then just building on my mac. Not awesome. |
The same happens for me. |
@shadowmint Unfortunately I don't have access to a Windows machine. I wonder if I should just removed all of the libs I'm using and reinstall. Not a huge deal, but I'd rather find out why this is happening when the only thing that appears different is the bower versions. |
I'll fix this in the next version. Thanks. |
That's awesome @rogerwang, thank you. Do you have an eta on the next version? Is there anything I can do now to work around this problem? |
@rogerwang FYI I also have an open thread on the Google Groups forum for this issue: https://groups.google.com/forum/#!topic/node-webkit/a6nFAx_U4Dc I've had several people respond with suggestions and potential causes. Still doesn't appear to be a definitive solution though. |
User @mauvm discovered on the node-webkit-boilerplate issues page that renaming I can confirm that renaming/moving |
Just let me know if there is anything I need to fix in https://github.com/shama/nodewebkit Thanks! |
Let me ask a really stupid question.. "Renaming/moving |
@shama There's a bug in https://github.com/rogerwang/node-webkit/blob/master/src/nw_package.cc#L256 which resolves to the wrong package.json in various circumstances as far as I can tell, but why it does that I'm not really sure, but I'm willing to get it's directly related to https://github.com/rogerwang/node-webkit/blob/master/src/nw_package.cc#L137 ie. The 3 level DirName() call is used in OSX to make it work in an app bundle, but when the code is not in an app bundle, this does weird things. |
@rawtaz For me simply renaming it to |
That's exactly what I did. I'm concerned though that when in ready to package there might be unknown impacts.
|
Cheers @mauvm that hack worked on my Lion-running Mac. Weird little bug this one, it loads most of the package.json in my project directory, but My nw was installed using npm. |
@rogerwang OSX's package.json search strategy lead to this problem.
So I think update this file will fix the bugs.I will have a try tomorrow. |
This should be working with latest version now. In 0.13 we changed to an optimized architecture so more features can be supported, see http://nwjs.io/blog/whats-new-in-0.13/ and it's good for keeping up with Chromium upstream -- we released with Node.js v6.0 and new Chromium versions within 1 day after upstream release. The new version would fixed many issues reported here and we're scrubbing them. This issue is closed as we believe it should be fixed. Please leave a message if it isn't and we'll reopen it. |
There are a few issues like #388 #831 where on OSX people seem to have difficulty running apps with valid package structure and/or package.json files. The general advice is that: you probably zipped it up wrong, like this:
Instead of:
However, there is actually a bug here.
If you have a local file called package.json, it clobbers the value inside the zip file.
Example of layout:
And in all.nw:
Running results in:
But it is valid:
The issue here is that the webkit working is incorrectly loading the wrong package.json file. The package.json in the current directory is being located instead. Indeed., removing the package.json file make it work perfectly.
This issue seems to be somehow related to the relative path of the node-webkit.app bundle and the source file.
Consider this directory structure:
Running:
Fails, while this works perfectly:
However, this also works perfectly:
So, it's got something to do with having a package.json in the same folder as the .nw file, or in the same folder as the app bundle.
Either way, very weird behaviour.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: