javascriptnode.jsnuxt.jsnode-modulespackage.json

Error: Cannot find module 'node:util' while running the nuxt project using npm run command


I created a new nuxt 2 project using the following commands

npm init nuxt-app <project-name>

after the npm install command when i try to run it using npm run dev it throws the follwing error (attached image)

internal/modules/cjs/loader.js:883 throw err;

^

Error: Cannot find module 'node:util' Require stack:

Package.json

{
  "name": "test",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate"
  },
  "dependencies": {
    "bootstrap": "^4.6.2",
    "bootstrap-vue": "^2.22.0",
    "core-js": "^3.25.3",
    "nuxt": "^2.15.8",
    "vue": "^2.7.10",
    "vue-server-renderer": "^2.7.10",
    "vue-template-compiler": "^2.7.10"
  },
  "devDependencies": {}
}

node version : v14.16.1 npm version : 6.14.12 nuxt version: 2.15.8

i've tried the following:

  1. deleting node_modules and package-lock npm cache clean --force npm i npm ci npm run dev

  2. installing nuxt utils

none of these work

screenshot


Solution

  • The problem has been solved by @r-rodrigues changing the nuxt version in package.json to "2.15.8" and removed the ^ (caret symbol) , which was upgrading the dependencies