yarn publish not respecting publishConfig in package.json

Created on 2 Feb 2018  路  15Comments  路  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?
bug

Detail
same as #5279
my comment on that issue:

publishConfig accepts not only access but also some other configs

Any config values can be overridden, but of course only "tag", "registry" and "access" probably matter for the purposes of publishing.

document

It seems like that fix just covers access case. At least tag and registry should also be covered as well

{
    "publishConfig": {
        "access": "public",
        "registry": "https://registry.npmjs.org/",
        "tag": "next"
      }
}
cat-compatibility triaged

Most helpful comment

Wow, I can't believe it's still not implemented. It looks like a very basic option of the publishing process.

We have a monorepo with a lot of private packages, that we want to publish to our internal registry and we are using both .npmrc and publishConfig. In .npmrc we specify the URL of our private read registry and in the publishConfig we specify our private registry for writing.

Also, we use scopes like this:

.npmrc => @acme:registry = https://acme.com/public/

  "publishConfig": {
    "@acme:registry": "https://acme.com/private/"
  },

We would definitely love to see this feature implemented.

All 15 comments

Thanks for pointing these out. It's an area of the config that I'd never used until now so wasn't sure what all made sense to implement. I'll see if I can work up a PR for this soon.

@rally25rs
In China, network connections to official package registry npmjs.com are unstable and slow.
To speed up installing packages, I use a registry mirror npm.taobao.org(widely used in China). And I set it as default globally.

But I can't publish packages to that registry since it's read-only. I have to publish them directly to official registry.

Meanwhile, I'm working on some scoped packages that should be published to our company private registry.

That's why I need publishConfig.registry to specify publish target for each package individually.

My problem is that I use yarn as npmclient for lerna to get the workspaces feature. However I want to publsih to my private npm registry using lerna publish. But since lerna uses yarn and yarn does not respect publishConfig for private npm registry, it seems I am stuck :-(. I cannot use npm for lerna publish without using npm for everything, which means giving up the workspaces feature.

UPDATE: I was able to work around this by adding a global config for the scope in .npmrc of my home directory. But for the case @tommytroylin mentions this is not possible, and I really think yarn should respect the publishConfig settings in package.json.

Btw, I tried with 1.4.1-20180206.0819 and the problem is still there.

@jonaskello Thats a nice to know workaround, but I agree, it would be better to support the publishConfig.

Actually my case, is the same as yours, I am also using lerna !

got same exact issue with lerna publish using yarn instead npm.
using YARN_REGISTRY worked on 1.4 but no longer help on 1.5

For the record: For those struggling with lerna and yarn, here is how I changed the registry for my organization scope:

yarn config set @SCOPE_NAME:registry https://registry.npmjs.org/

@tommytroylin I'm now facing the same problem you described. I wanted to use yarn as lerna client to publish packages to our company-private-registry(cnpm), but failed. Did you find a solution?

@aprilandjan
I publish private packages with lerna + yarn like this:

lerna publish --skip-npm

then

lerna exec npm publish

@tommytroylin Thanks for your solution, It is very helpful! I updated yarn from 1.6.0 to latest version (currently it is1.9.2), and successfully publish private modules to cnpm using command lerna publish. Sorry I didn't read the detailed changes between version changes.

@aprilandjan
My pleasure~ Is this means that yarn has fixed it already?

@tommytroylin I assume so 馃槂

Wow, I can't believe it's still not implemented. It looks like a very basic option of the publishing process.

We have a monorepo with a lot of private packages, that we want to publish to our internal registry and we are using both .npmrc and publishConfig. In .npmrc we specify the URL of our private read registry and in the publishConfig we specify our private registry for writing.

Also, we use scopes like this:

.npmrc => @acme:registry = https://acme.com/public/

  "publishConfig": {
    "@acme:registry": "https://acme.com/private/"
  },

We would definitely love to see this feature implemented.

@slavafomin I guess it hasn't been enough of a pain-point for anyone to submit a PR to fix it. If you are willing to write up a fix, we'd love the additional support from the community! 馃樃

@rally25rs It has been a big pain point, but you can publish with npm instead.

I have the same scenario as @slavafomin, but I realized that the problem is caused by the scope defined in both .npmrc and publishConfig. if I remove the scope it works.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danez picture danez  路  3Comments

MunifTanjim picture MunifTanjim  路  3Comments

torifat picture torifat  路  3Comments

victornoel picture victornoel  路  3Comments

NonPolynomial picture NonPolynomial  路  3Comments