Search code examples
node.jsreactjsrollup

Rollup build issue always says cannot find module node:process


I am facing issue tried many things including changing node versions, removing node_modules and re-installing all dependencies but still not found any solution. I need help to solve this issue .

I want to create a library but stuck here .

Error when I run command of rollup enter image description here

  {
  "name": "typescript-template",
  "version": "0.1.0",
  "private": true,
  "main": "lib/cjs/index.js",
  "module": "lib/esm/index.js",
  "dependencies": {
    "@emotion/react": "^11.10.5",
    "@emotion/styled": "^11.10.5",
    "@mui/material": "^5.11.6",
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "@types/jest": "^27.5.2",
    "@types/node": "^16.18.11",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "storybook": "start-storybook -p 6006 -s public",
    "build-storybook": "build-storybook -s public",
    "build-rollup": "rollup --config",
    "build-tsc": "tsc"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ],
    "overrides": [
      {
        "files": [
          "**/*.stories.*"
        ],
        "rules": {
          "import/no-anonymous-default-export": "off"
        }
      }
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@rollup/plugin-babel": "^6.0.3",
    "@rollup/plugin-commonjs": "^24.0.1",
    "@rollup/plugin-node-resolve": "^15.0.1",
    "@rollup/plugin-typescript": "^11.0.0",
    "@storybook/addon-actions": "^6.5.15",
    "@storybook/addon-essentials": "^6.5.15",
    "@storybook/addon-interactions": "^6.5.15",
    "@storybook/addon-links": "^6.5.15",
    "@storybook/builder-webpack5": "^6.5.15",
    "@storybook/manager-webpack5": "^6.5.15",
    "@storybook/node-logger": "^6.5.15",
    "@storybook/preset-create-react-app": "^4.1.2",
    "@storybook/react": "^6.5.15",
    "@storybook/testing-library": "0.0.13",
    "@types/react": "^18.0.27",
    "babel-plugin-named-exports-order": "0.0.2",
    "node-process": "^1.0.1",
    "prop-types": "^15.8.1",
    "react": "^18.2.0",
    "rollup": "^3.11.0",
    "rollup-plugin-filesize": "^9.1.2",
    "rollup-plugin-peer-deps-external": "^2.2.4",
    "rollup-plugin-postcss": "^4.0.2",
    "rollup-plugin-terser": "^7.0.2",
    "typescript": "^4.9.4",
    "webpack": "^5.75.0"
  },
  "peerDependencies": {
    "@types/react": "^18.0.27",
    "@types/react-dom": "^18.0.10",
    "react": "^18.2.0"
  }
}

When i have visited this rollup js file then i found that they are requiring node:process enter image description here

I want to solve this node:process not found issue.


Solution

  • I was having the same problem with my Rollup configuration and was able to fix it by upgrading my Node.js version from 14.15.1 to 14.19.3 which is a more stable version, so you can try upgrading to a more stable version of node.

    And just in case you need it, you can use nvm to have installed different versions of NodeJS in the same environment. You can take a look at this tutorial on how to install it in Windows: NVM for windows.

    I know that this is more a workaround than a real fix to the problem but I wasn't able to find more information about this issue.

    Hope this can help you.