Please help me with the connection of the library. Install the following library - node-gost ( https://github.com/romansopov/crypto )

I'm trying to connect it to my project like this:

const gost = require("../../node_modules/node-gost/index"); 

so

 import * as gost from "../../node_modules/node-gost/index"; 

I get the error: Module not found: Can't resolve 'gostRandom' in '/ home / user / project / node_modules / node-gost / lib'.

Content index.js library:

 module.exports = require('./lib/gostCrypto'); require('./lib/gostASN1'); require('./lib/gostCert'); require('./lib/gostCipher'); require('./lib/gostCMS'); require('./lib/gostCoding'); require('./lib/gostDigest'); require('./lib/gostEngine'); require('./lib/gostKeys'); require('./lib/gostRandom'); require('./lib/gostSecurity'); require('./lib/gostSign'); require('./lib/gostViewer'); 

The library has a test file test.js, in which the connection works correctly.

 const gost = require('./index'); console.log(gost); 
  • one
    require("node-gost"); have you tried? - Darth
  • @Darth, yes. Connecting as const gost = require ("node-gost"), I get the same error. - karlmr95

1 answer 1

checked on npm 5.5.1 + node9.2.0 works.

Package.json

 { "name": "gost-test", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "node-gost": "^1.0.0" } } 

index.js

 const gost = require('node-gost') console.log(gost) 

Terminal:

 node .\index.js { subtle: SubtleCrypto {}, getRandomValues: [Function], coding: GostCoding {}, security: {}, asn1: {}, cert: GostCert {}, cms: GostCMS {}, keys: GostKeys {} } 
  • The fact of the matter is that I put it from npm npmjs.com/package/node-gost - karlmr95
  • hmm npmjs search did not find it. You are right she is there. I just checked and it works. What version of nodejs do you have? My npm 5.5.1 node v9.2.0. - Roman Mik
  • npm 3.10.8, node v6.9.1 I don’t think it's the version. All the same, the test.js file from the library runs and works as expected. The problem is to include this library in the project. - karlmr95
  • Other libraries connect without problems? Through require ()? - Roman Mik
  • Honestly, up to this point I used connections through import, as import {push} from "react-router-redux"; Through require () now I tried to connect other libraries - it does not work. - karlmr95