digitalbazaar / eslint-config-digitalbazaar

BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

Linting doesn't work with `npm i --only dev` #33

Open mattcollier opened 4 years ago

mattcollier commented 4 years ago

For some reason, an ajv eslint dependency does not get installed when trying to install only dev dependencies in order to lint a bedrock module. This problem is resolved if one just does a regular npm i. I don't know if there's anything DB can do about this.

EDIT: The symptoms are... vscode silently fails to lint the code. If you do npx eslint . or similar, you will get the message about the missing dep.

mattcollier commented 4 years ago

OK, I've finally been able to identify the root cause of this issue:

The ajv dependency referenced above was a bit of a red herring. Turns out, the NPM algorithm does not install ANY dependencies that are ALSO regular dependencies. In another cases, this commonly results in the same situation with lodash as with ajv above.

Put another way. If the top level package has a regular dependency on lodash and eslint is a dev dependency. Doing npm install --only=dev will not install the lodash dependency required by eslint: https://github.com/eslint/eslint/blob/master/package.json#L73

Which means of course that eslint cannot function. Which is why our lint scripts and vscode will not function with --only=dev.

https://github.com/npm/npm/issues/12184