swapi-graphql icon indicating copy to clipboard operation
swapi-graphql copied to clipboard

npm install not working on Windows - Unable to set NODE_ENV Environment Variable

Open coding-jj opened this issue 4 years ago • 1 comments

Description

npm install will not work on MS Windows 10. The system ins not able to set Environment Variable NODE_ENV

Please make swapi-graphql work with Windows 10.

Steps to Reproduce

  • Git clone Project to Windows
  • Open Windows Powershell in swapi-graphql directory
  • Run npm install

Error will occur:

> swapi-graphql@ build:lambda D:\z_git_jj\_graphql\swapi-graphql
> NODE_ENV=development netlify-lambda build handler

Der Befehl "NODE_ENV" ist entweder falsch geschrieben oder konnte nicht gefunden werden.
Translation: The Command "NODE_ENV" is either misspelled or could not be found.

Solution

  • npm install cross-env
  • Edit Line 40 in package.json "build:lambda" - Add cross-env before setting variable
  • Run npm install

package.json:

    "build:lambda": "cross-env NODE_ENV=development netlify-lambda build handler",

Further Readings

Stackoverflow: How to set environment variables from within package.json

coding-jj avatar Dec 23 '20 17:12 coding-jj

I ran into the same problem, but just changed the same line to SET NODE_ENV instead of installing an additional package. Works like a charm! :)

antonstalheim avatar Feb 24 '21 14:02 antonstalheim