The filename package.json
is actually hardcoded into npm source code and you cannot change it using a configuration option or a command line flag.
While this is not a verified reason from developers, I suspect the reason for not allowing this is that it would break dependency resolution. If package A renames its package.json to myapp.json, and package B specifies A as its dependency, then npm would be unable to read and install A's dependencies (or any metainformation, for that matter) because of the non-standard package.json's name.
If you search npm's repo, you will find 100+ mentions both in source and tests that directly reference the string package.json.
PS. If your application requires a npm module to be installed globally, you should either
- Clearly state this in README and detect its presence at runtime (and print a nice error message to the user if it is missing)
- Invest time and effort into making it work with local installation (subjectively preferred)