dfx deploy Error: [webpack-cli] Error: Cannot find module 'dotenv'

149 Views Asked by At

I was getting below error as I was using latest version of dfx dfx 0.14.3. After running dfx deploy on terminal getting below error.

Error:

Stderr:
    [webpack-cli] Failed to load '/home/navalega0109/ic-projects/dkeeper/webpack.config.js' config
    [webpack-cli] Error: Cannot find module 'dotenv'
    Require stack:
    - /home/navalega0109/ic-projects/dkeeper/webpack.config.js
    - /home/navalega0109/ic-projects/dkeeper/node_modules/webpack-cli/lib/webpack-cli.js
    - /home/navalega0109/ic-projects/dkeeper/node_modules/webpack-cli/lib/bootstrap.js
    - /home/navalega0109/ic-projects/dkeeper/node_modules/webpack-cli/bin/cli.js
    - /home/navalega0109/ic-projects/dkeeper/node_modules/webpack/bin/webpack.js
        at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
        at Module._load (node:internal/modules/cjs/loader:922:27)
        at Module.require (node:internal/modules/cjs/loader:1143:19)
        at require (node:internal/modules/cjs/helpers:110:18)
        at Object.<anonymous> (/home/navalega0109/ic-projects/dkeeper/webpack.config.js:1:1)
        at Module._compile (node:internal/modules/cjs/loader:1256:14)
        at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
        at Module.load (node:internal/modules/cjs/loader:1119:32)
        at Module._load (node:internal/modules/cjs/loader:960:12)
        at Module.require (node:internal/modules/cjs/loader:1143:19) {
      code: 'MODULE_NOT_FOUND',
      requireStack: [
        '/home/navalega0109/ic-projects/dkeeper/webpack.config.js',
        '/home/navalega0109/ic-projects/dkeeper/node_modules/webpack-cli/lib/webpack-cli.js',
        '/home/navalega0109/ic-projects/dkeeper/node_modules/webpack-cli/lib/bootstrap.js',
        '/home/navalega0109/ic-projects/dkeeper/node_modules/webpack-cli/bin/cli.js',
        '/home/navalega0109/ic-projects/dkeeper/node_modules/webpack/bin/webpack.js'
      ]
    }
1

There are 1 best solutions below

0
On

Solution

The above issue got resolve after installing npm install --save dotenv

Error was coming because webpack.config file of latest version uses require("dotenv").config();

Whereas this line of code was not there in webpack.config of older version.

enter image description here