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

Remove the requirement for a second package.json in the app folder #577

Closed
tjvantoll opened this issue Jun 19, 2015 · 3 comments
Closed

Comments

@tjvantoll
Copy link
Contributor

As of NativeScript 1.1.1 I can now keep my npm modules in the root folder of my NativeScript project, which is awesome. After I got that working I wanted to remove the package.json within my project's app folder, as that file didn't seem to have any purpose anymore. But when I do that I get an error, as the CLI seems to be using the app/package.json file's "main". So I had to keep around a basic package.json for my app to work:

{
    "main": "app.js"
}

Is there any chance this configuration can move to the root package.json or just go away entirely—aka why can't we just default the app's main file to be app.js so a project only needs to have one package.json?

Thanks.

@RangerMauve
Copy link

Personally, I'm mostly peeved that I have to shove stuff into an app folder at all. It'd be nice if the root of the project was used for the source. In that case, the package.json at the root could be the main package.json, and the tns_modules and node_modules could just be in the root as well.

@ligaz
Copy link

ligaz commented Jun 20, 2015

Hey @tjvantoll,

The problem with this is that the runtimes fail to resolve which is your main. The current workflow is like this:

if (exists(package.json) && package.json.contains(main))
   load(package.json.main)
else if (exists(index.js))
   load(index.js)
else if (exists(bootstrap.js))
   load(bootstrap.js)    

We have been discussing that we can provide a fallback for app.js as well. Alternatively we can just prepare the root package.json into the correct place. I will circle this around and will update you here what we can do to improve this.

@ligaz
Copy link

ligaz commented Feb 26, 2016

With 1.6.0 we have introduced --template option for project creation that uses npm packages for project templates. This yields that the package.json in the app folder will stay if we do not want to artificially delete it after template expansion.

@ligaz ligaz closed this as completed Feb 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants