Does a Node.js package.json need to be at the root of the repository?
git, github, javascript, node.js, package.json
Solution
If I set the repository field in package.json to point to the parent repository, will that work?
Yes. This field is not used by any critical npm functionality. It's just so if contributors want to clone a repo so they can work on the project.
Will anything break because the package.json file is not at the root of that repository (npm, in particular)?
No. I don't believe anything will break.
- You should set the `repository` field to the parent project's top-level `.git` path. The purpose of this field is for SCM (git, etc) to be able to clone the project. In your case, the closest thing is the parent project. This should avoid the warning message.
- You should set the `bugs` field to the issues page. This should then show up on the npm web site. I don't think `repository` and `bugs` are related directly or any assumptions are made about one based on the other by npm.
- If you don't otherwise have a web site for it, you could set `homepage` to the github URL to the directory containing this npm module within the parent repo. Stick a README.md file there and github will render it below the directory contents.
Problem
I have a Node.js package that currently resides in a subdirectory of a GitHub repository. I can currently publish it without setting the repository field, but then my users will get a warning and there is less useful information on the Node Package Repository page than their could be (issues and pull requests links are missing). If I set the `repository` field in `package.json` to point to the parent repository, will that work? Will anything break because the `package.json` file is not at the root of that repository (npm, in particular)?