问题
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:
- Download the binaries from https://code.google.com/archive/p/openssl-for-windows/downloads
- Extract to
C:\OpenSSL-Win32\
(or whatever name you want to give it). - Add the system environment variable
OPENSSL_CONF
with valuec:\OpenSSL-Win32\openssl.cnf
(points to the config file where you extrated the binaries) - Add
C:\OpenSSL-Win32\bin
to yourPath
environment variable - 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