Dotenv: Cannot find module: 'dotenv' on linux

Created on 30 May 2019  路  2Comments  路  Source: motdotla/dotenv

We have a build that has worked on multiple linux and OS X platforms (netlify, heroku, local, raspberry pi linux, etc/) until we added dotenv. Now, on all platforms (except OS X) we get the following error:

$ yarn build
yarn run v1.16.0
$ react-scripts build
Creating an optimized production build...
Failed to compile.

/home/user/git/spec/shared/user.js
Cannot find module: 'dotenv'. Make sure this package is installed.

You can install this package by running: yarn add dotenv.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Most helpful comment

I did, and I also tried with only npm. We're using dozens of packages, and the only one to have this problem is dotenv, thus the report

package.json:
"dependencies": {
"archiver": "^3.0.0",
"body-parser": "^1.19.0",
"chai-fs": "^2.0.0",
"chai-string": "^1.5.0",
"cors": "^2.8.5",
"dotenv": "^8.0.0",
"dotenv-extended": "^2.4.0",
"esm": "^3.2.25",
"express": "^4.17.1",
"express-basic-auth": "^1.2.0",
"form-data": "^2.3.3",
"lodash": "^4.17.11",
"mongodb": "^3.2.6",
"mongoose": "^5.5.11",
"morgan": "^1.9.1",
"multer": "^1.4.1",
"sync-request": "^6.1.0"
},

All 2 comments

Did you add dotenv as a dependency with yarn?

Closing as this is not an issue with dotenv itself

I did, and I also tried with only npm. We're using dozens of packages, and the only one to have this problem is dotenv, thus the report

package.json:
"dependencies": {
"archiver": "^3.0.0",
"body-parser": "^1.19.0",
"chai-fs": "^2.0.0",
"chai-string": "^1.5.0",
"cors": "^2.8.5",
"dotenv": "^8.0.0",
"dotenv-extended": "^2.4.0",
"esm": "^3.2.25",
"express": "^4.17.1",
"express-basic-auth": "^1.2.0",
"form-data": "^2.3.3",
"lodash": "^4.17.11",
"mongodb": "^3.2.6",
"mongoose": "^5.5.11",
"morgan": "^1.9.1",
"multer": "^1.4.1",
"sync-request": "^6.1.0"
},

Was this page helpful?
0 / 5 - 0 ratings

Related issues

datasmurfen picture datasmurfen  路  5Comments

goldbergyoni picture goldbergyoni  路  3Comments

marcusradell picture marcusradell  路  3Comments

shellscape picture shellscape  路  3Comments

DesignByOnyx picture DesignByOnyx  路  4Comments