Home
Support Forums

Node env or context not available in netlify function

Hello, I recently began to use netlify function which is great for my stripe payment form. In the lambda endpoint, though, I can’t access NODE_ENV or CONTEXT : it’s undefined. I need them to determine if i’m in test mode or live mode. I’m running the command netlify dev and here is my package.json:

"scripts": {
    "build": "cross-env NODE_ENV=production npm-run-all clean -p build:*",
    "build:11ty": "eleventy --quiet",
    "build:css": "tailwindcss -i src/_bundle/main.pcss -o dist/assets/main.bundle.css --minify --postcss",
    "build:js": "esbuild src/_bundle/main.js --outfile=dist/assets/main.bundle.js --bundle --platform=browser --target=es2017",
    "clean": "rm -rf dist",
    "start": "cross-env NODE_ENV=development npm-run-all -p dev:*",
    "dev:11ty": "eleventy --serve --quiet",
    "dev:css": "tailwindcss -i src/_bundle/main.pcss -o dist/assets/main.bundle.css --watch --postcss",
    "dev:js": "esbuild src/_bundle/main.js --outfile=dist/assets/main.bundle.js --bundle --watch --platform=browser --target=es2017"
  },

Hi @NicolasK,

There are many posts in the forums about the same issue. You would have to use a plugin to solve this problem: netlify-plugin-inline-functions-env - npm