46

I have my own private npm registry http://something. I installed yarn and trying to run following command.

yarn

But it is giving following error.

Trace: 
  Error: unable to get local issuer certificate
      at Error (native)
      at TLSSocket.<anonymous> (_tls_wrap.js:1017:38)
      at emitNone (events.js:67:13)
      at TLSSocket.emit (events.js:166:7)
      at TLSSocket._init.ssl.onclienthello.ssl.oncertcb.TLSSocket._finishInit (_tls_wrap.js:582:8)
      at TLSWrap.ssl.onclienthello.ssl.oncertcb.ssl.onnewsession.ssl.onhandshakedone (_tls_wrap.js:424:38)

I found couple of github issue and resolution as well.

https://github.com/yarnpkg/yarn/issues/841 https://github.com/yarnpkg/yarn/commit/b0611a6ee5220b0b1e955b271b6140640158f96c (Available in 0.16.0)

Looks like i have to set strict-ssl to false in yarn config. I am unable to find exactly how can I do that. I tried giving option in following ways in package.json but didn't work.

1)

{
config: {
"strict-ssl": false
}
}

2)

{
"strict-ssl": false
}

But still I am getting same error. Where am I doing wrong?

Aurora0001
  • 13,139
  • 5
  • 50
  • 53
thecodejack
  • 12,689
  • 10
  • 44
  • 59

4 Answers4

115

There is possibility that you are getting the error because you are running behind a proxy server. To fix this, open Node.js command prompt; type and execute the following command:

yarn config set "strict-ssl" false -g
ziizium
  • 7
  • 1
  • 3
Sundara Prabu
  • 2,361
  • 1
  • 21
  • 20
  • 12
    However, note that `-g` means it is set *globally*. To be a little safer, one could leave it off and run `yarn config set "strict-ssl" false` only if and when needed. – allenjom Jul 02 '19 at 16:26
  • saved my day. thanx :) – Kundan Sep 01 '23 at 09:18
18

Realised that config needs to get into .yarnrc file. I have set following to get it worked.

cafile null
strict-ssl false

Also please note that yarn also takes config options from .npmrc file as well.

thecodejack
  • 12,689
  • 10
  • 44
  • 59
  • I get an error regarding the cafile, but this DOES work - only if you put it inside the .yarnrc file, NOT inside the .npmrc file. – raingod Feb 08 '17 at 23:23
  • 3
    @raingod Did you get the error, `error Could not open cafile: ENOENT: no such file or directory, open '/project/dir/null'` ? – BrianRT Feb 11 '17 at 21:25
8

The command has been updated. The command is now:

yarn config set enableStrictSsl false
Francis Ade
  • 328
  • 3
  • 8
0

For me the problem was a corrupted installation of node.

Uninstalling all related: node, npm, nvm, yarn; and reinstalling the packages anew solved the problem.

dianakarenms
  • 2,609
  • 1
  • 22
  • 22