I'm trying to test solidity code with truffle. As the number values returned from (or sent to) contracts are BigNumbers I want to require the library. My current test is a one-liner:
let BigNumber = require('bignumber.js');
called hello_test.js.
If I run npm ls -g | grep bignumber I can see +-- [email protected], so it's installed; but if I try:
truffle.cmd test .\test\hello_test.js
I get
Error: Cannot find module 'bignumber.js'
What's going on?
Truffle version 4.0.6, npm version 5.6.0
This is the way node require works:
require('xx')will search forIf it can not find, it will go ahead to search by the environmental variable,
NODE_PATH. If that is not specified, it won't search any global module.So you can check your
NODE_PATH.