Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module 'fs-extra' when testing with Truffle

I am reading the tutorial on Ethereum Pet Shop -- Your First DApp, everything seems ok until I test with truffle test with below error:

Error: Cannot find module 'fs-extra'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.call (/Users/.npm-global/lib/node_modules/truffle/node_modules/@truffle/debugger/dist/external "fs-extra":1:18)
at r (/Users/.npm-global/lib/node_modules/truffle/node_modules/@truffle/debugger/dist/webpack/bootstrap:19:22)
[...]
Truffle v5.2.4 (core: 5.2.4)
Node v10.16.0

I have tried some suggestions as in Module is extraneous npm, but the Error: Cannot find module 'fs-extra' insists.

like image 583
nambk Avatar asked Sep 19 '25 04:09

nambk


1 Answers

You need to add it to your package.json and install the package.

  1. Either run

    npm install --save fs-extra
    

    The --save option will add it to the package.json for you.

  2. Or add it manually to the package.json section dependencies

    "dependencies": {
        "fs-extra": "^9.1.0"
    }
    

    and then install it

    npm install
    

    Version 9.1.0 is the current version according to npmjs

like image 114
Petr Hejda Avatar answered Sep 23 '25 12:09

Petr Hejda