Ramakrishna Kadali
Ramakrishna Kadali

Reputation: 11

Issue with use of env-cmd in react application

System:

OS: Windows 10 IDE: Visual Studio Code

I'm working on a react application which contains below package.json

{
  "name": "test-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "animakit-expander": "^2.1.4",
    "animakit-rotator": "^2.1.3",
    "axios": "^0.19.0",
    "circular-json": "^0.5.9",
    "env-cmd": "^10.0.1",
    "file-saver": "^2.0.2",
    "jquery": "^3.4.1",
    "jsonwebtoken": "^8.5.1",
    "jszip": "^3.2.2",
    "mdbreact": "^4.22.1",
    "rc-queue-anim": "^1.8.2",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-if-elseif-else-render": "^1.0.2",
    "react-lazylog": "^4.4.1",
    "react-loading-overlay": "^1.0.1",
    "react-native-orientation-loading-overlay": "^0.1.6",
    "react-overlay-loader": "0.0.3",
    "react-overlay-loading": "^1.0.3",
    "react-scripts": "3.2.0",
    "react-scrollbar": "^0.5.6",
    "react-transition-group": "^4.3.0",
    "reactjs-popup": "^1.5.0",
    "reactstrap": "^8.1.1",
    "velocity-react": "^1.4.3"
  },
  "scripts": {
    "start": "env-cmd -f ./.env.dev react-scripts start",
    "start-dev": "env-cmd -f ./.env.dev react-scripts start",
    "test": "react-scripts test --coverage",
    "eject": "react-scripts eject",
    "build": "react-scripts build",
    "start1": "react-scripts start"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

When I run the command in the terminal, npm run start, I'm facing below issue:

> [email protected] start C:\dev\test-app
> env-cmd -f ./.env.dev react-scripts start

'-f' is not recognized as an internal or external command,
operable program or batch file.
spawn  -f ENOENT
internal/process/per_thread.js:189
      throw errnoException(err, 'kill');
      ^

Error: kill ENOSYS
    at process.kill (internal/process/per_thread.js:189:13)
    at TermSignals._terminateProcess (C:\dev\test-app\node_modules\env-cmd\dist\signal-termination.js:47:28)
    at process.terminateSpawnedProcessFuncHandlers.<computed> (C:\dev\test-app\node_modules\env-cmd\dist\signal-termination.js:20:30)
    at Object.onceWrapper (events.js:300:26)
    at process.emit (events.js:210:5)
    at process.exit (internal/process/per_thread.js:158:15)
    at TermSignals._uncaughtExceptionHandler (C:\dev\test-app\node_modules\env-cmd\dist\signal-termination.js:68:17)
    at process.<anonymous> (C:\dev\test-app\node_modules\env-cmd\dist\signal-termination.js:40:53)
    at process.emit (events.js:210:5)
    at process._fatalException (internal/process/execution.js:150:25) {
  errno: 'ENOSYS',
  code: 'ENOSYS',
  syscall: 'kill'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 7
npm ERR! [email protected] start: `env-cmd -f ./.env.dev react-scripts start`
npm ERR! Exit status 7
npm ERR!
npm ERR! Failed at the [email protected] start 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!     C:\Users\me\AppData\Roaming\npm-cache\_logs\2020-01-09T07_15_50_457Z-debug.log

and where as, when I run env-cmd -f ./.env.dev react-scripts start directly in any terminal, my application is working fine.

Please provide your suggestions.

Upvotes: 1

Views: 5380

Answers (1)

nbsamurai
nbsamurai

Reputation: 346

Can you try placing the .env.dev file at the same folder level as package.json and try running the script by changing it to

env-cmd -f .env.dev react-scripts start

Upvotes: 1

Related Questions