paixaop / node-sodium

Port of the lib sodium encryption library to Node.js
MIT License
351 stars 126 forks source link

Installing on Windows Failed #164

Closed dev-whoan closed 3 years ago

dev-whoan commented 3 years ago
npm install sodium --unsafe-perm --save
npm ERR! code 1
npm ERR! path \mynode\node_modules\sodium
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node install.js --preinstall
npm ERR! MS Version: 2015
npm ERR! Preinstall Mode
npm ERR! Download libsodium.lib
npm ERR! MS Version: 2015
npm ERR! Platform Tool is v140
npm ERR! Download: https://raw.githubusercontent.com/paixaop/libsodium-bin/master/1.0.16/x64/Release/v140/dynamic/libsodium.dll
npm ERR! fs.js:168
npm ERR!     throw new ERR_INVALID_CALLBACK(cb);
npm ERR!     ^
npm ERR!
npm ERR! TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received undefined
npm ERR!     at makeCallback (fs.js:168:11)
npm ERR!     at Object.unlink (fs.js:1199:14)
npm ERR!     at ClientRequest.<anonymous> (\mynode\node_modules\sodium\install.js:149:12)
npm ERR!     at ClientRequest.emit (events.js:315:20)
npm ERR!     at TLSSocket.socketErrorListener (_http_client.js:469:9)
npm ERR!     at TLSSocket.emit (events.js:315:20)
npm ERR!     at emitErrorNT (internal/streams/destroy.js:106:8)
npm ERR!     at emitErrorCloseNT (internal/streams/destroy.js:74:3)
npm ERR!     at processTicksAndRejections (internal/process/task_queues.js:80:21) {
npm ERR!   code: 'ERR_INVALID_CALLBACK'
npm ERR! }

Here is what I did

$ npm config set msvs_version 2015
$ npm install node-gyp -g
$ npm install
$ npm install sodium

I have run CMD as administrator. How can I fix it?

dev-whoan commented 3 years ago

Here how I fixed

  1. Install VS 2015 Development C++ tools
  2. Install VS 2019 Development C++ tools
  3. $ npm config set msvs_version 2017
    $ npm install node-gyp -g
    $ npm install
    $ npm install npm -g
    $ npm install sodium