Looking at openfaas
Node templates there is a pattern of having a nested package.json
in the functions
folder.
Seeing a nested package.json file (location other than the root) in a non-monorepo npm package is code smell to me and causes some dev flow problems:
- A nested
package-lock.json
artifact being committed - cloning the repo and running
npm ci
does not install all the dependencies
The latter is particularly painful. A developer cloning an openfaas repo for the first time and running npm ci
or npm i
will not have all the dependencies installed to run the function locally. Same issue for any continuous integration, like Jenkins, that runs automated tests.
So one could add the dependencies in the function/package.json
to the root package.json
(prone to human error). Or write scripts that cd function && npm ci && cd .. && npm run start:whatever
to work around this but obviously that is a bit ridiculous.
- Does
openfaas
require the package.json dependency manifest for publishing/runtime purposes? - If not, why does
openfaas
suggest this nestedpackage.json
infunction
directory pattern for it's Node templates