Truffle: Cannot find module 'truffle-expect'

Created on 1 Jul 2017  路  14Comments  路  Source: trufflesuite/truffle

  • [x] I've asked for help in the Truffle Gitter before filing this issue.

Issue

Made a fresh truffle install today (my first). When using truffle migrate with the 'truffle init' project I get an error saying cannot find truffle-expect. Error remained after doing:
sudo npm install -g truffle-expect

Steps to Reproduce

new install of truffle
npm install -g truffle
mkdir newproj
cd newproj
truffle init
truffle compile
truffle migrate

Expected Behavior

no error

Actual Results

Error: Cannot find module 'truffle-expect'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:85773:14)
at __webpack_require__ (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:21:30)
at Object. (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:59914:15)
at __webpack_require__ (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:21:30)
at Object.run (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:84660:19)
at Command.run (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:60901:20)

Environment

  • Operating System: Ubuntu 16.04
  • Truffle version: v3.3.1
  • Ethereum client: geth 1.6.6-stable-10a45cb5
  • node version: v7.10.0
  • npm version: 5.0.4
bug needs reproduced

Most helpful comment

I posted the "fix" above but it sounds like this issue has been resolved just not deployed yet. You can follow the accepted answer in that StackOverflow.com question in the meantime to resolve the issue using -

$ npm install -g truffle-expect truffle-config web3

All 14 comments

I got same erro
Cannot find module 'truffle-expect'

I have got the same error.

npm install -g truffle-expect

I have tried using sudo npm install -g truffle-expect
but it gives me error 馃憤

Error: Cannot find module 'truffle-config'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object. (/usr/lib/node_modules/truffle/build/cli.bundled.js:85774:14)
at __webpack_require__ (/usr/lib/node_modules/truffle/build/cli.bundled.js:21:30)
at Object. (/usr/lib/node_modules/truffle/build/cli.bundled.js:59914:15)
at __webpack_require__ (/usr/lib/node_modules/truffle/build/cli.bundled.js:21:30)
at Object.run (/usr/lib/node_modules/truffle/build/cli.bundled.js:84660:19)
at Command.run (/usr/lib/node_modules/truffle/build/cli.bundled.js:60901:20)

then i have tried
sudo npm install -g truffle-config
it gives error like this

npm ERR! code 1
npm ERR! Command failed: /usr/bin/git clone -q https://github.com/debris/bignumber.js.git /home/ubuntu/.npm/_cacache/tmp/git-clone-59b5be4d
npm ERR! /home/ubuntu/.npm/_cacache/tmp/git-clone-59b5be4d/.git: Permission denied
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR! /home/ubuntu/.npm/_logs/2017-07-04T05_12_40_507Z-debug.log

Same issue on a fresh fresh docker container from node:latest.

# truffle init
Downloading project...
Project initialized.

  Documentation: http://truffleframework.com/docs

Commands:

  Compile: truffle compile
  Migrate: truffle migrate
  Test:    truffle test

# truffle compile
Compiling ./contracts/ConvertLib.sol...
Compiling ./contracts/MetaCoin.sol...
Compiling ./contracts/Migrations.sol...
Writing artifacts to ./build/contracts

# truffle test
Error: Cannot find module 'truffle-expect'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:85773:14)
    at __webpack_require__ (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:21:30)
    at Object.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:59914:15)
    at __webpack_require__ (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:21:30)
    at Object.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:201851:15)
    at __webpack_require__ (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:21:30)

I posted the "fix" above but it sounds like this issue has been resolved just not deployed yet. You can follow the accepted answer in that StackOverflow.com question in the meantime to resolve the issue using -

$ npm install -g truffle-expect truffle-config web3

@PWKad that did the trick. Thanks!

I ran everything above, says this now.

rkraig@rkraig-vmware-16 ~/projects/work/janus/ethereum/sample-1 $ truffle migrate
Error: Cannot find module 'xhr2'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/truffle-config/node_modules/web3/lib/web3/httpprovider.js:38:12)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
node: 8.1.3
npm: 5.0.3
Truffle v3.3.1
ubuntu: 16.04

This isssue has been reported here as well: #478

Even after running npm install -g truffle-expect truffle-config web3 I still cannot execute truffle migrate cmd.

It still fails with:
Cannot find module 'truffle-expect' at Function.Module._resolveFilename (module.js:485:15) at Function.Module._load (module.js:437:25) at Module.require (module.js:513:17) at require (internal/module.js:11:18) at Object.<anonymous>.

It's very strange as I see all packages (truffle-expect, truffle-config and truffle) in my npm-global directory at /Users/username/.npm-packages/lib/node_modules/...
I tried to re-install truffle-expect, truffle-config and truffle globally several times, but it has no effect. My OP is Mac OS Sierra, I'm using npm/node installed via homebrew.

@egortsaryk9
same as you, after running npm install -g truffle-expect truffle-config web3 still has the error Cannot find module 'truffle-expect'

I'm on windows and I can't install truffle-config. web3 and truffle-expect installed just fine, but config errors out.

It was my bad. I had 2 versions of truffle, the old 3.3.1 at /Users/username/.node/bin/truffle and the newest 3.4.5 at /Users/username/.npm-packages/bin/truffle. So truffle were linked to 3.3.1 path that didn't contain all required packages. Make sure you have correct paths if you use homebrew (https://gist.github.com/DanHerbert/9520689)

This seems pretty old and likely out of date. Closing, but let me know if the problem still persists on newer versions of Truffle and I will reopen. Thanks!

Was this page helpful?
0 / 5 - 0 ratings