1

I have a node/express/react application I am building using create-react-app for the client side. Whenever I run npm run build I get this error:

> [email protected] build /Users/crescentfresh/myApp/client
> react-scripts build

module.js:487
    throw err;
    ^

Error: Cannot find module 'dotenv-expand'
    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 dotenvFiles.forEach.dotenvFile (/Users/crescentfresh/myApp/client/node_modules/react-scripts/config/env.js:43:5)
    at Array.forEach (native)
    at Object.<anonymous> (/Users/crescentfresh/myApp/client/node_modules/react-scripts/config/env.js:41:13)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/crescentfresh/.npm/_logs/2018-10-09T23_53_36_314Z-debug.log

This is my package.json for my create-react-app directory:

{
  "name": "frontend",
  "version": "0.1.0",
  "private": true,
  "proxy": {
    "/api/*": {
      "target": "http://localhost:3000"
    }
  },
  "dependencies": {
    "@uppy/core": "^0.27.3",
    "@uppy/dashboard": "^0.27.5",
    "@uppy/react": "^0.27.5",
    "@uppy/tus": "^0.27.5",
    "apollo-cache-inmemory": "^1.2.5",
    "apollo-client": "^2.3.5",
    "apollo-link": "^1.2.2",
    "apollo-link-error": "^1.1.0",
    "apollo-link-http": "^1.5.4",
    "apollo-link-state": "^0.4.1",
    "axios": "^0.18.0",
    "bootstrap": "^4.1.1",
    "graphql": "^0.13.2",
    "graphql-tag": "^2.9.2",
    "prop-types": "^15.6.2",
    "react": "^16.4.1",
    "react-apollo": "^2.1.9",
    "react-dom": "^16.4.1",
    "react-router": "^4.3.1",
    "react-router-dom": "^4.3.1",
    "react-scripts": "2.0.3",
    "react-spinners": "^0.4.5",
    "reactstrap": "^6.2.0",
    "recompose": "^0.29.0"
  },
  "scripts": {
    "start": "cross-env PORT=3003 react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "devDependencies": {
    "cross-env": "^5.2.0"
  }
}

This used to build but recently began failing. I tried removing the packages that were added sometime before the failed builds happened but that didn't help (uppy and axios packages) so I am not sure if that's even related.

If there's anything else I should include please let me know.

5
  • it is most likely because of Node.js version. try to use stable version of node and you also can use nvm in order to switch between different versions Commented Oct 10, 2018 at 0:23
  • @SaJed I am using 8.1.1 that should be stable right? Commented Oct 10, 2018 at 0:46
  • Have you tried installing the missing module 'dotenv-expand'? Commented Oct 10, 2018 at 0:49
  • @crescentfresh 8.1.1 is stable, have you tried to reinstall create-react-app ? Commented Oct 10, 2018 at 1:27
  • @SaJed I will give that a try. Thanks! Commented Oct 10, 2018 at 5:33

2 Answers 2

2

Please run this command to resolve the error.

npm i dotenv-expand
Sign up to request clarification or add additional context in comments.

Comments

1

There are many problems that may lead to this problems i.e,React,npm,the package source.Maybe run this in terminal npm i --save-dev dotenv-expand / yarn add --save-dev dotenv-expand

1 Comment

Thanks for the response. This resolved the error but left me with a new one. I'm thinking something is corrupted and I should just clone my repo again and start over. My friend isn't getting the same error on his machine so I have to assume I have something screwy in my local environment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.