Error message "Module 'node:process' not found" occures while working with fastify-cli globally on Mac operating system

I recently set up a new Mac development machine and successfully installed node, npm, and nvm. Everything was working fine in one project directory until I tried to install and use fastify-cli and encountered the following error:

internal/modules/cjs/loader.js:892
  throw err;
  ^

Error: Cannot find module 'node:process'
Require stack:
- /Users/a/.nvm/versions/node/v14.17.5/lib/node_modules/fastify-cli/node_modules/marked-terminal/index.cjs
- /Users/a/.nvm/versions/node/v14.17.5/lib/node_modules/fastify-cli/node_modules/blessed-contrib/lib/widget/markdown.js
- /Users/a/.nvm/versions/node/v14.17.5/lib/node_modules/fastify-cli/node_modules/blessed-contrib/index.js
- /Users/a/.nvm/versions/node/v14.17.5/lib/node_modules/fastify-cli/docs.js
- /Users/a/.nvm/versions/node/v14.17.5/lib/node_modules/fastify-cli/cli.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
    at Function.Module._load (internal/modules/cjs/loader.js:745:27)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/Users/a/.nvm/versions/node/v14.17.5/lib/node_modules/fastify-cli/node_modules/marked-terminal/index.cjs:3:17)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/a/.nvm/versions/node/v14.17.5/lib/node_modules/fastify-cli/node_modules/marked-terminal/index.cjs',
    '/Users/a/.nvm/versions/node/v14.17.5/lib/node_modules/fastify-cli/node_modules/blessed-contrib/lib/widget/markdown.js',
    '/Users/a/.nvm/versions/node/v14.17.5/lib/node_modules/fastify-cli/node_modules/blessed-contrib/index.js',
    '/Users/a/.nvm/versions/node/v14.17.5/lib/node_modules/fastify-cli/docs.js',
    '/Users/a/.nvm/versions/node/v14.17.5/lib/node_modules/fastify-cli/cli.js'
  ]
}

To reproduce this issue, follow these steps:

  1. $ npm install --global fastify-cli
    (successful)
  2. $ fastify generate myproject (resulting in the above error)
  3. $ fastify (also leading to the same error message)

This problem seems unrelated to fastify. It appears that the global package is unable to locate Node for some reason, although I could be mistaken.

  • I am using zshell
  • Xcode is installed on my system
  • I have updated my version of Node
  • I can run a fastify app directly from the app directory without using the generator

Any insights or suggestions would be greatly appreciated!

Answer №1

After encountering an error, I found a solution by referring to a reply in this GitHub thread

The use of node internal syntax (e.g.: node:<core_module_name>) is not compatible with Node.js 14.16.0

To resolve the issue, it was necessary to have a minimum node version of 14.18

Here are the steps that were taken:

  1. Upgraded node to version 14.18.0 using nvm, the latest LTS in the 14.x series.
  2. Set the default version to 14.18.0 or higher.

Answer №2

Make sure to execute the following command:
npm install @types/node

Answer №3

My solution involved changing the current user to a root user.

For Mac users, consider switching to a root user account and attempting the task again.

I initially designated my previous account as 'administrator' in system preferences, but this did not resolve the problem. The issue was resolved when I switched to my primary account.

I hope this tip proves helpful!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Converting a base64 image to an image object in Node.js: A comprehensive guide

My frontend implementation utilizes React, where the input accepts image files. ... onImageChange = event => { if (event.target.files && event.target.files[0]) { let img = event.target.files[0]; //This is the image object //The ...

challenges encountered while trying to incorporate browserify

I have a situation where I have two .js files located in the same folder. File app.js : import {foo} from 'custom'; foo(); File custom.js : function foo(){ $('.nav.navbar-nav > li').on('click', function(e) { $(&ap ...

Accessing view, model, or collection property in AJAX 'beforeSend' with Backbone.js

Currently in my node application I am utilizing Backbone.js to handle various ajax calls from views, models and collections. To keep track of these calls, I have created a custom property named "myName" in each view, model and collection, with a unique v ...

Continuous Crashes Plaguing Heroku Application

Update after implementing modifications: /app/index.js:27 2016-12-07T16:03:32.984832+00:00 app[web.1]: liveQuery: { 2016-12-07T16:03:32.984833+00:00 app[web.1]: ^^^^^^^^^ 2016-12-07T16:03:32.984838+00:00 app[web.1]: SyntaxError: Unexpected identifier ...

Leveraging client API callback variables within a Node.js backend system

If I send a request on the client side using the code snippet below public/foo.js function bar() { fetch('https://api.github.com/') .then(response => response.json()) .then(data => { console.log(data) }) .catch( ...

After clicking on the checkbox, req.body.task becomes undefined

Whenever I click on the checkbox, the value of req.body.task returns as undefined. <input type="checkbox" name="task" autocomplete="off" checked="" onchange="onToDochange({{id}})"> This function is triggered by a change event on the checkbox and it ...

npm malfunctioning after being installed through brew

Encountering a problem while setting up Node, npm, and cordova+ionic on my High Sierra Mac. Here's the issue: Julime-Air:~ julime$ brew install node ==> Downloading https://homebrew.bintray.com/bottles/node-9.3.0_1.high_sierra.bottle.tar.gz Alread ...

Axios - Error: Promise Rejected - The request was unsuccessful with a 500 status code

The Axios post request in my code for adding new articles is not going through, and I am encountering an error: Failed to load resource: the server responded with a status of 500 (Internal Server Error) createError.js:17 Uncaught (in promise) Error: Requ ...

Where the package.json file resides

Is there a designated location for the package.json file in a project, like within the project directory? Where should the package.json file be located in a multi-component project? What is the significance of having version 0.0.0 in th ...

Setting up a recurring task upon launching Express: How to Create a Scheduled Job

After starting to learn Express, I encountered an issue. My app is successfully serving a REST API, but I wanted to incorporate a scheduled job using node-schedule (https://www.npmjs.com/package/node-schedule). Here is how I set up this module: var schedu ...

issue encountered while attempting to install oracledb using npm

When attempting to install node oracledb on Windows 7, I encountered an error message. Here is a screenshot of the error: npm install oracledb I diligently followed all the steps outlined in this tutorial Installing node-oracledb on Microsoft Windows, but ...

The benefits of using express-session-mongo compared to creating your own solution

Being new to nodejs/mongo, I decided to create my own session middleware instead of using the express-session-mongo plugin. In my custom middleware, I save the user's id in the session (via express's session middleware) and retrieve the logged-i ...

I'm encountering an issue where the command "node" is not found, even though the full path is working. How can I get the command "node -v" to work properly?

After recently installing node.js, I encountered an issue when trying to confirm the installation by running 'node -v' in my command shell. Instead of getting the version number, I received a "bash: node: command not found" error message. Searchi ...

What is the process of incorporating npm packages into a .NET Core project within Visual Studio 2019?

As I venture into the world of front end development using React in conjunction with .NET Core for backend, I find myself grappling with new tools and technologies. My task is to utilize Visual Studio 2019 for working with .NET Core, a development enviro ...

Encountering difficulty installing a private npm package within GitHub Actions

Having a private npm package within my organization that is crucial for my project, I have encountered an issue while trying to build the project in a different repository. Despite successfully creating tokens and publishing the package from a separate wor ...

Karma test parameter "watch=false" is not functioning as expected

We encountered an issue while running our Jasmine tests. When we execute: ng test --browsers=ChromeHeadless --code-coverage the tests are successful. However, if we run: ng test --watch=false --browsers=ChromeHeadless --code-coverage it fails and we r ...

Encountering an issue when trying to execute the npm start command in the Windows 10 command prompt

Need assistance with a React error. I encounter this screen when attempting to run the command npm start after creating a new React project. ...

Is it possible to view the frames/packets being transmitted from an EJS or HTML form to the Express backend using Express Js?

My current computer science assignment involves visually representing the data transfer process between a frontend and backend. I don't need to show the full data, just the flow of chunks and how it navigates through protocols. Could someone please g ...

In node.js, the global variable scope is returning an [Object object] rather than a string

In my request function, I successfully receive the tokenName in the response. However, I am struggling to access it globally so that I can save it in the database. request(options,function (error, response, body) { tokenName = body.notification_key ...

Leveraging NPM 'pre' commands

Utilizing NPM, we have the ability to implement pre scripts to function as pre hooks (in addition to post hooks). In my case, I am aiming to execute 'gulp default' prior to running my npm script in the following manner: "scripts":{ "prestart ...