spotless: spotless/prettier - .npmrc seems to be ignored

My company is using a different registry for npm, specified by .npmrc:

registry = https://artifacthub.company.com/api/npm/npm-virtual/
sass_binary_site = https://artifacthub.company.com/node-bindings/4.10.0/
disturl = https://artifacthub.company.com/nodejs/

It appears that spotless is not picking those up. Is there any way I can add this as parameter to the prettier format? (essentially it needs to run npm install -registry=.... ...)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 20 (12 by maintainers)

Most upvoted comments

No-obligation ping to @simschla just in case you have a broader vision for how you’d like to handle this

Personally, I’ve never used the npmrc. Based on the documentation, the most project-specific approach is to have a .npmrc file next to the package.json when running npm.

I think this would fit into the current api, using a similar approach to the npmExecutable setting:

prettier().npmExecutable('/usr/bin/npm').npmrc('/path/to/my/.npmrc').config(...)

(Another approach would be to try do autodiscover the .npmrc file by looking at the locations ${project.projectDir}/.npmrc, ${rootProject.projectDir}/.npmrc and $HOME/.npmrc - but even such an approach would need a possibility to override the location)

What do you think?

ok, so I’ll update the docs and create the PR.