我正在尝试所有可能的方法来创建一个React应用程序。我尝试过Maven,现在我正在尝试从Facebook孵化器创建-反应-应用程序。

当我尝试在npm环境中运行create-react-app my-app命令时,它在我的个人系统上运行没有问题。但是,当我在我的工作环境中尝试相同的命令时,我在命令行上遇到了以下错误:

npm ERR! node v6.10.2
npm ERR! npm  v3.10.10
npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY

npm ERR! unable to get local issuer certificate
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

当前回答

按照下面的步骤,我解决了这个问题。

npm config set strict-ssl=false
npm config set registry http://registry.npmjs.org/
npm config set cafile /path/to/your/cert.pem
set NODE_TLS_REJECT_UNAUTHORIZED=0

其他回答

同样的错误。看起来它与SSL证书有关。如果您正在对公共包使用NPM(不需要HTTPS的安全性),您可以使用以下命令关闭严格的SSL密钥验证。

如果您只是希望一次性安装几个公开可用的软件包,这可能是最简单的解决方案。

npm config set strict-ssl=false

这个问题很容易解决。

错误

npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY 
npm ERR! errno UNABLE_TO_GET_ISSUER_CERT_LOCALLY
npm ERR! request to https://registry.npmjs.org/yarn failed, reason: unable to get local issuer certificate  
npm ERR! A complete log of this run can be found in:

解决方案

如果您在组织或内部网中,请使用以下推荐。

NPM配置注册表 https://type_your_org_repo_fqdn

其他明智的

NPM配置设置注册表http://registry.npmjs.org/

对我来说,问题是VPN,我断开了VPN和“npm I”命令工作,没有失败。

NPM配置设置注册表http://registry.npmjs.org/

如果这个代码技巧对你不起作用,那么试着从主目录运行你的应用程序。这对我很管用。

我从C:\Users\MyUser中删除了.npmrc文件,它工作了