---
title: "How do you fix \"ReferenceError: primordials is not defined\"?"
description: "primordials is not defined appears when an old gulp 3 or graceful-fs runs on a newer Node.js. Upgrade the tooling or switch to a compatible Node.js version."
url: "https://bugsee.com/answers/ionic/referenceerror-primordials-is-not-defined/"
---

# How do you fix "ReferenceError: primordials is not defined"?

An old tool, usually gulp 3 with an outdated `graceful-fs`, is running on a Node.js version newer than it supports. Upgrade gulp and the dependencies, or switch to an older Node.js with nvm.

Newer Node.js versions removed internals that old releases of `graceful-fs` relied on. Build tools that bundle that old version fail at startup with this error, which is common in older Ionic and Cordova projects.

- Quick fix: use a Node.js version that the project was built for, for example `nvm install 10 && nvm use 10`.
- Real fix: upgrade gulp to 4 or later (or move to the framework's current build tooling) and update the Ionic CLI.
- If the culprit is a transitive dependency, check with `npm ls graceful-fs` and update the package that pulls in the old version, or use an `overrides` entry to force `graceful-fs` to 4.2 or later.

```bash
npm ls graceful-fs
nvm use 10
npm install gulp@4 --save-dev
```

Pin the Node.js version in `.nvmrc` or `engines` so the team and CI use the same one.

## Related questions

- [How do you lazy load images in Angular and Ionic?](https://bugsee.com/answers/ionic/angular-lazy-load-images/)
