npm install openssl failed on windows 10

╄→尐↘猪︶ㄣ 提交于 2019-12-07 18:04:29

问题


I am running the following command in Node.js command window in Win10. It failed. anyone has ideas how to fix it? I am running Node.js v7.3.0

C:\Users\haozhang>npm install openssl
C:\Users\haozhang
`-- openssl@1.1.0
  +-- mout@0.11.1
  `-- nyks@2.31.3
    +-- async@2.1.5
    | `-- lodash@4.17.4
    `-- mout@1.0.0

npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\haozhang\package.json'
npm WARN haozhang No description
npm WARN haozhang No repository field.
npm WARN haozhang No README data
npm WARN haozhang No license field.

C:\Users\haozhang>openssl
'openssl' is not recognized as an internal or external command,
operable program or batch file.

回答1:


As mentionned by Royi Mindel the npm openssl package is just a wrapper around the openssl binaries and not the actual openssl. You need to install openssl on your Windows 10 machine as follows:

  1. Download the binaries from https://code.google.com/archive/p/openssl-for-windows/downloads
  2. Extract to C:\OpenSSL-Win32\ (or whatever name you want to give it).
  3. Add the system environment variable OPENSSL_CONF with value c:\OpenSSL-Win32\openssl.cnf (points to the config file where you extrated the binaries)
  4. Add C:\OpenSSL-Win32\bin to your Path environment variable
  5. Open a cmd or PowerShell and type openssl version. It should work and you should see the version installed

Info taken from: https://www.tbs-certificates.co.uk/FAQ/en/openssl-windows.html




回答2:


By looking at the commands you are running, it seems like you are trying to use the installed npm module as an external command. You can achieve this only by installing the module globally:

npm install -g openssl

The warnings you get are expected. Each time you install a module locally, npm will try to update your package.json with the dependency to the module. Since you probably don't have a package.json in your home directory, you get the warning.



来源:https://stackoverflow.com/questions/42918916/npm-install-openssl-failed-on-windows-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!