简体   繁体   中英

Error: Cannot find module './build/Release/scrypt'

I try to learn a little bit js and solidity right know and bought a udemy course. My bad. The guy who made it let the course outdated and there is no longer a support or someone who answere questions...

Anyway when I try to test with mocha my code I get this error:

Error: Cannot find module './build/Release/scrypt'

The Errorlog:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'test'
1 verbose cli ]
2 info using npm@6.14.8
3 info using node@v14.15.1
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info lifecycle udem@1.0.0~pretest: udem@1.0.0
6 info lifecycle udem@1.0.0~test: udem@1.0.0
7 verbose lifecycle udem@1.0.0~test: unsafe-perm in lifecycle true
8 verbose lifecycle udem@1.0.0~test: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\User\stuff\sol\udem\node_modules\.bin;C:\Python39\Scripts\;C:\Python39\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Acer ProShield\;C:\Program Files\Acer ProShield\x86;C:\Program Files\Git\cmd;C:\Program Files\PuTTY\;C:\Program Files\PostgreSQL\10\bin;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Users\User\.windows-build-tools\python27\;C:\Program Files\Python\Scripts\;C:\Program Files\Python\;C:\Users\User\AppData\Local\Microsoft\WindowsApps;C:\Users\User\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\User\Desktop\Alles\Proggen\InstagrammBOT;C:\Users\User\AppData\Roaming\npm
9 verbose lifecycle udem@1.0.0~test: CWD: C:\Users\User\stuff\sol\udem
10 silly lifecycle udem@1.0.0~test: Args: [ '/d /s /c', 'mocha' ]
11 silly lifecycle udem@1.0.0~test: Returned: code: 1  signal: null
12 info lifecycle udem@1.0.0~test: Failed to exec test script
13 verbose stack Error: udem@1.0.0 test: `mocha`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1048:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid udem@1.0.0
15 verbose cwd C:\Users\User\stuff\sol\udem
16 verbose Windows_NT 10.0.18363
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "test"
18 verbose node v14.15.1
19 verbose npm  v6.14.8
20 error code ELIFECYCLE
21 error errno 1
22 error udem@1.0.0 test: `mocha`
22 error Exit status 1
23 error Failed at the udem@1.0.0 test script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Thats the code:

const assert = require('assert');
const ganache = require ('ganache-cli');
const Web3 = require('web3');

const web3 = Web3(ganache.provider);


class Car {
    park() {
        return 'stopped';
    }
    drive() {
        return 'vroom';
    
    }
}

describe('CarTest (just a string)', ()=> {
    it('can park (just a string)',() =>{
        const car = new Car();
        assert.equal(car.park(), 'stopped');
    });
});

Yeah Im new with js and solidity so I have no clue... Hope someone can help.

This error can be resolved easily. Go to node_modules/scrypt/tests/index.js or if the tests folder not present then just search of index.js in node_module/scrypt folder And there change this line var scryptNative = require(“./build/Release/scrypt”) to this line var scryptNative = require("scrypt") . And boom. I hope this will definitely helps you.
One More Suggestion you are missing Parenthesis in your tests.js file after .provider

. use this line const web3 = new Web3(ganache.provider());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM