shirakaba / react-nativescript

React renderer for NativeScript
https://react-nativescript.netlify.com
MIT License
280 stars 14 forks source link

`npm install` failing due to missing `package.json` #24

Closed LeslieOA closed 5 years ago

LeslieOA commented 5 years ago

Hey @shirakaba.

Had a little downtime so started to look into react-nativescript and noticed that for those who may use npm over yarn, they'd be hit with the following error:

npm ERR! premature close

Adding a package.json seems to solve this (e.g. here https://github.com/LeslieOA/react-nativescript).

Hope this helps/let me know if a PR would be more helpful.

Peace.

shirakaba commented 5 years ago

Discussion from Slack:

I think this may be happening merely because I've specified in my instructions to install my git repo, but my git repo isn't in the form of an npm package. It's still in a logical layout, however – it mirrors that of NativeScript-Angular.

I shall update the instructions to recommend taking a clone of the project and running npm link relative to that clone (at least until I publish a release version).

[A root-level package.json] has no semantic meaning purpose other than to let users npm install from the GitHub repo, however.

In retrospect, I shouldn't have given that as an instruction, because my GitHub repo is not set up as a node module, and if users do follow those instructions, they will have to pull my sample app and maybe all of its dependencies in (even though they just want the react-nativescript library).

The existing package.json in react-nativescript/react-nativescript/package.json is what users will receive when they install any releases via npm. It specifies which files to distribute when publishing an npm module, as well as the dependencies of the framework, and lives alongside a node_modules folder that the src directory refers to. So it's semantic and purposeful.

An extra repo-root-level package.json would also likely lead to dependency issues. The dependencies of react-nativescript are specified and imported from our inner-level package.json. If a user installs via GitHub, I think it'll see the root-level package.json and get very confused about why no dependencies are listed.

Closed by 512dbf9. Thanks for the Issue filing! Hoping these new instructions work better.