0

Node version is 14

Nuxt 2.16.3

npm install works fine, but while running npm run build I got the error Cannot find module 'node:fs'

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

/home/jenkins/workspace/test/node_modules/rc9/dist/index.cjs
/home/jenkins/workspace/test/node_modules/@nuxt/config/dist/config.js
/home/jenkins/workspace/test/node_modules/@nuxt/cli/dist/cli-index.js
/home/jenkins/workspace/test/node_modules/@nuxt/cli/dist/cli.js
/home/jenkins/workspace/test/node_modules/nuxt/bin/nuxt.js

 at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
 at Function.Module._load (internal/modules/cjs/loader.js:725:27)
 at Module.require (internal/modules/cjs/loader.js:952:19)
 at require (internal/modules/cjs/helpers.js:88:18)
 at Object.<anonymous> (/home/jenkins/workspace/test/node_modules/rc9/dist/index.cjs:3:17)
 at Module._compile (internal/modules/cjs/loader.js:1063:30)
 at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
 at Module.load (internal/modules/cjs/loader.js:928:32)
 npm ERR! code ELIFECYCLE

pacakge.json

{
    "version": "1.0.0",
    "author": "test",
    "private": true,
    "scripts": {
        "dev": "nuxt",
        "build": "nuxt build",
        "start": "nuxt start",
        "test": "jest -u - runInBand - coverage - passWithNoTests",
        "generate": "nuxt generate",
        "lint": "eslint - ext .js,.vue - ignore-path .gitignore .",
        "lint:fix": "eslint - fix - ext .js,.vue - ignore-path .gitignore .",
        "lint:css": "stylelint - fix ./**/*.{vue,scss,css}"
    },
    "lint-staged": {
        "*.{js,vue}": "npm run lint:fix",
        "*.{css,vue}": "npm run lint:css"
    },
    "husky": {
        "hooks": {
            "pre-commit": "lint-staged"
        }
    },
    "dependencies": {
        "@babel/compat-data": "7.19.4",
        "@babel/core": "7.21.3",
        "@babel/generator": "7.19.6",
        "@babel/helper-compilation-targets": "7.19.3",
        "@babel/helper-create-class-features-plugin": "7.19.0",
        "@babel/helper-module-transforms": "7.19.6",
        "@babel/preset-env": "7.12.17",
        "@nuxtjs/axios": "5.12.2",
        "@nuxtjs/dotenv": "1.4.0",
        "@nuxtjs/proxy": "2.0.1",
        "@nuxtjs/pwa": "3.0.0–0",
        "@nuxtjs/vuetify": "1.11.3",
        "axios": "0.21.0",
        "babel-polyfill": "6.26.0",
        "bootstrap-vue": "2.21.2",
        "cookie-universal-nuxt": "2.1.4",
        "cross-env": "5.2.1",
        "jest": "26.6.0",
        "jest-circus": "26.6.0",
        "jest-resolve": "26.6.0",
        "jest-sonar-reporter": "2.0.0",
        "jest-webpack-resolver": "0.3.0",
        "json5": "2.2.1",
        "jsonwebtoken": "8.5.1",
        "lodash": "4.17.20",
        "moment": "2.29.1",
        "nuxt": "2.16.3",
        "nuxt-i18n": "6.28.1",
        "vue-jest": "3.0.7",
        "vuex-persist": "3.1.3"
    },
    "devDependencies": {
        "@nuxtjs/eslint-config": "2.0.0",
        "@nuxtjs/eslint-module": "1.0.0",
        "@nuxtjs/stylelint-module": "3.1.0",
        "babel-eslint": "10.0.1",
        "eslint": "6.1.0",
        "eslint-plugin-nuxt": ">=0.4.2",
        "eslint-plugin-vue": "6.2.2",
        "lint-staged": "10.0.0",
        "node-sass": "6.0.1",
        "sass-loader": "10.3.1",
        "stylelint": "10.1.0",
        "stylelint-config-standard": "20.0.0"
    },
    "config": {
        "nuxt": {
            "host": "0.0.0.0"
        }
    },
    "engines": {
        "node": "16.x"
    }
}

Can anyone help, please?

I have already tried reinstalling modules with npm cache clean --force

I am facing this issue only in the Jenkins machine and the same command works fine with local

Bravo
  • 61
  • 2
  • 7
  • 26

0 Answers0