Node.js ReferenceError: process is not defined

Hi all,

Since I deployed a new version of my Node.js application the ‘process’ object seems to be undefined:

ReferenceError: process is not defined
at Object.<anonymous> (/usr/src/app/app.js:15:11)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

I can’t see any change in my application which could have caused this issue. start script in package.json is ‘node app.js’. I’m using the process object to read the environment variables.

Does anybody know what could have caused this issue?


Hi, can you please share relevant piece of code please?

Code is:

const request = require('./request');
const fs = require("fs");
const firebase = require('@firebase/app').default;

const lastUpdateFile = '/data/lastupdate.txt';
const assetDir = '/data/assets_import/';
const ip = 'localhost';

// const lastUpdateFile = './lastupdate.txt';
// const assetDir = './assets_import/';
// const ip = '';

const firebaseConfig = {
apiKey: process.env.APIKEY,
authDomain: process.env.AUTHDOMAIN,
databaseURL: process.env.DATABASEURL,
projectId: process.env.PROJECTID,
storageBucket: process.env.STORAGEBUCKET,
messagingSenderId: process.env.MESSAGINGSENDERID,

const cbid = process.env.CBID;
const cfDomain = process.env.CFDOMAIN;

Basically the error is shown on the very first usage of process.env.*:

apiKey: process.env.APIKEY,

Thanks for your support on this!

I finally found the issue. Later on in the code I had a function named ‘process’ :man_facepalming:

Renaming this function solved the issue.