nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.65k stars 2.36k forks source link

NextJS build fails without error on Ubuntu #10696

Closed anthonyma94 closed 2 years ago

anthonyma94 commented 2 years ago

Current Behavior

When I run nx run client:build:production, the process fails with no errors. The terminal cursor then disappears. The build runs fine on Windows.

Expected Behavior

I expect the build to run without errors.

Steps to Reproduce

  1. Install nx using sudo npm install -g yarn nx.
  2. Run yarn install.
  3. Run nx run client:build:production.

I have run this on Ubuntu 22.04, in a VSCode dev container, and on Windows 10. The build fails on Ubuntu and dev container.

Failure Logs

There are no failure logs, even with --verbose. The last log before failure is Collecting page data..., then it goes to this:

 >  NX   Running target "client:build" failed

   Failed tasks:

   - client:build:production

.

Environment

Node : 16.14.2
   OS   : linux x64
   yarn : 1.22.18

   nx : 13.9.7
   @nrwl/angular : Not Found
   @nrwl/cypress : 13.9.7
   @nrwl/detox : Not Found
   @nrwl/devkit : 13.9.7
   @nrwl/eslint-plugin-nx : 13.9.7
   @nrwl/express : 13.9.7
   @nrwl/jest : 13.9.7
   @nrwl/js : 13.9.7
   @nrwl/linter : 13.9.7
   @nrwl/nest : Not Found
   @nrwl/next : 13.10.3
   @nrwl/node : 13.9.7
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 13.9.7
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 13.9.7
   @nrwl/web : 13.9.7
   @nrwl/workspace : 13.9.7
   typescript : 4.3.5
   rxjs : 6.6.7
   ---------------------------------------
   Community plugins:
AgentEnder commented 2 years ago

Hey @anthonyma94 , it may be unrelated, but some of your @nrwl/* packages don't line up with the version of nx you have installed. Aside from @nrwl/nx-cloud, all packages under the nrwl scope should generally be set up with the same version.

Can you correct this and check that the issue still reproduces? An easy way to fix this would be to run nx migrate {v}, where v is the version of nx you have installed. Alternatively, updating to latest with nx migrate latest would also work.

anthonyma94 commented 2 years ago

Hey @AgentEnder, sorry for the late reply. I'm trying to do nx migrate 13.9.7, but it keeps throwing the following error:

 ERROR  The migrate command failed.

Command failed: yarn add -W @nrwl/workspace@13.9.7
warning "@nrwl/workspace > nx > @swc-node/register@1.5.1" has unmet peer dependency "typescript@>= 4.3".
warning "@nrwl/workspace > @nrwl/linter > @phenomnomnominal/tsquery@4.1.1" has unmet peer dependency "typescript@^3 || ^4".
error /tmp/tmp-10459-KKCzWGym7q0c/node_modules/@nrwl/workspace: Command failed.
Exit code: 1
Command: node ./src/init/init
Arguments: 
Directory: /tmp/tmp-10459-KKCzWGym7q0c/node_modules/@nrwl/workspace
Output:
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'typescript'
Require stack:
- /tmp/tmp-10459-KKCzWGym7q0c/node_modules/@nrwl/workspace/src/utilities/typescript/compilation.js
- /tmp/tmp-10459-KKCzWGym7q0c/node_modules/@nrwl/workspace/src/utilities/typescript.js
- /tmp/tmp-10459-KKCzWGym7q0c/node_modules/@nrwl/workspace/src/core/target-project-locator.js
- /tmp/tmp-10459-KKCzWGym7q0c/node_modules/@nrwl/workspace/src/core/project-graph/build-dependencies/explicit-project-dependencies.js
- /tmp/tmp-10459-KKCzWGym7q0c/node_modules/@nrwl/workspace/src/core/project-graph/build-dependencies/index.js
- /tmp/tmp-10459-KKCzWGym7q0c/node_modules/@nrwl/workspace/src/core/project-graph/build-project-graph.js
- /tmp/tmp-10459-KKCzWGym7q0c/node_modules/@nrwl/workspace/src/core/project-graph/project-graph.js
- /tmp/tmp-10459-KKCzWGym7q0c/node_modules/@nrwl/workspace/src/init/init.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/tmp/tmp-10459-KKCzWGym7q0c/node_modules/@nrwl/workspace/src/utilities/typescript/compilation.js:7:12)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/tmp/tmp-10459-KKCzWGym7q0c/node_modules/@nrwl/workspace/src/utilities/typescript/compilation.js',
    '/tmp/tmp-10459-KKCzWGym7q0c/node_modules/@nrwl/workspace/src/utilities/typescript.js',
    '/tmp/tmp-10459-KKCzWGym7q0c/node_modules/@nrwl/workspace/src/core/target-project-locator.js',
    '/tmp/tmp-10459-KKCzWGym7q0c/node_modules/@nrwl/workspace/src/core/project-graph/build-dependencies/explicit-project-dependencies.js',
    '/tmp/tmp-10459-KKCzWGym7q0c/node_modules/@nrwl/workspace/src/core/project-graph/build-dependencies/index.js',
    '/tmp/tmp-10459-KKCzWGym7q0c/node_modules/@nrwl/workspace/src/core/project-graph/build-project-graph.js',
    '/tmp/tmp-10459-KKCzWGym7q0c/node_modules/@nrwl/workspace/src/core/project-graph/project-graph.js',
    '/tmp/tmp-10459-KKCzWGym7q0c/node_modules/@nrwl/workspace/src/init/init.js'
  ]
}

I've double-checked the tmp folder, typescript indeed does not exist in there. However it exists in the project node_modules, and in package.json:

{
  "name": "name",
  "license": "MIT",
  "scripts": {
    "start": "nx serve",
    "build": "nx build",
    "test": "nx run-many --target=test --all",
    "test-build": "nx run-many --target=build --configuration=production --projects=api,client",
    "test-build:all": "nx run-many --target=build --configuration=production --all",
    "api:prod": "node -r dotenv/config dist/apps/api/main.js dotenv_config_path=apps/api/.env",
    "release": "dotenv release-it --",
    "knex": "cross-env TS_NODE_PROJECT=tsconfig.base.json ts-node-dev -r tsconfig-paths/register node_modules/knex/bin/cli.js --knexfile libs/utils/objection-js-utils/src/config/knex-cli.ts",
    "migrate:make": "yarn knex migrate:make",
    "migrate": "yarn knex migrate:latest",
    "seed:make": "yarn knex seed:make",
    "seed": "yarn knex seed:run",
    "rollback": "yarn knex migrate:rollback",
    "reset-db": "cross-env TS_NODE_PROJECT=tsconfig.base.json ts-node-dev -r tsconfig-paths/register libs/services/data-services/src/reset.ts",
    "build-storybook": "yarn nx run utils-react-utils:build-storybook",
    "chromatic": "npx chromatic"
  },
  "private": true,
  "dependencies": {
    "@docusaurus/core": "^2.0.0-beta.21",
    "@docusaurus/preset-classic": "^2.0.0-beta.21",
    "@emotion/react": "11.9.0",
    "@emotion/server": "^11.4.0",
    "@emotion/styled": "11.8.1",
    "@mdx-js/react": "^1.6.21",
    "@mui/icons-material": "^5.0.4",
    "@mui/lab": "^5.0.0-alpha.53",
    "@mui/material": "^5.0.4",
    "@nrwl/next": "13.10.3",
    "@sentry/integrations": "^7.0.0",
    "@sentry/nextjs": "^7.0.0",
    "@sentry/node": "^7.0.0",
    "@sentry/tracing": "^7.0.0",
    "@storybook/core-server": "6.4.22",
    "aedes": "^0.46.3",
    "async-mutex": "^0.3.2",
    "axios": "^0.24.0",
    "clsx": "^1.1.1",
    "concat-stream": "^2.0.0",
    "conventional-changelog": "^3.1.24",
    "cookie-parser": "^1.4.6",
    "core-js": "^3.6.5",
    "cors": "^2.8.5",
    "dayjs": "^1.10.7",
    "eventsource": "^2.0.0",
    "express": "4.17.2",
    "fast-csv": "^4.3.6",
    "global": "^4.4.0",
    "helmet": "^5.0.2",
    "http-status-codes": "^2.2.0",
    "inversify": "^5.1.1",
    "inversify-binding-decorators": "^4.0.0",
    "json2csv": "^5.0.6",
    "just-clone": "^5.0.1",
    "just-compare": "^2.1.0",
    "knex": "^0.95.11",
    "mongoose": "6.2.4",
    "mqtt": "^4.3.4",
    "msw": "^0.39.2",
    "mysql2": "^2.3.0",
    "next": "12.1.2",
    "node-schedule": "^2.1.0",
    "nodemailer": "^6.7.2",
    "notistack": "^2.0.3",
    "objection": "^2.2.16",
    "prepend-file": "^2.0.0",
    "react": "17.0.2",
    "react-dnd-touch-backend": "^15.1.1",
    "react-dom": "17.0.2",
    "react-hook-form": "^7.21.2",
    "react-is": "18.0.0",
    "react-query": "^3.34.0",
    "react-sortablejs": "^6.1.1",
    "react-table": "^7.7.0",
    "react-use": "^17.3.2",
    "reflect-metadata": "^0.1.13",
    "regenerator-runtime": "0.13.7",
    "rxjs": "~6.6.3",
    "socket.io": "^4.3.1",
    "socket.io-client": "^4.3.2",
    "sortablejs": "^1.14.0",
    "swagger-express-ts": "^1.1.0",
    "swagger-ui-dist": "^4.8.0",
    "ts-node": "^10.4.0",
    "tslib": "^2.0.0",
    "winston": "^3.3.3",
    "winston-daily-rotate-file": "^4.6.1",
    "zod": "^3.14.4"
  },
  "devDependencies": {
    "@babel/core": "7.12.13",
    "@commitlint/cli": "^15.0.0",
    "@commitlint/config-conventional": "^15.0.0",
    "@cypress/react": "^5.12.4",
    "@docusaurus/module-type-aliases": "^2.0.0-beta.21",
    "@emotion/babel-plugin": "11.7.2",
    "@emotion/babel-preset-css-prop": "^11.2.0",
    "@next/bundle-analyzer": "^12.0.8",
    "@nrwl/cli": "13.9.7",
    "@nrwl/cypress": "13.9.7",
    "@nrwl/devkit": "13.9.7",
    "@nrwl/eslint-plugin-nx": "13.9.7",
    "@nrwl/express": "13.9.7",
    "@nrwl/jest": "13.9.7",
    "@nrwl/linter": "13.9.7",
    "@nrwl/node": "13.9.7",
    "@nrwl/react": "13.9.7",
    "@nrwl/storybook": "13.9.7",
    "@nrwl/web": "13.9.7",
    "@nrwl/workspace": "13.9.7",
    "@sentry/webpack-plugin": "^1.18.9",
    "@storybook/addon-docs": "~6.4.12",
    "@storybook/addon-essentials": "~6.4.12",
    "@storybook/addon-interactions": "^6.4.19",
    "@storybook/builder-webpack5": "~6.4.12",
    "@storybook/client-api": "^6.4.19",
    "@storybook/manager-webpack5": "~6.4.12",
    "@storybook/react": "~6.4.12",
    "@storybook/testing-library": "^0.0.9",
    "@storybook/testing-react": "^1.2.3",
    "@svgr/webpack": "^5.4.0",
    "@testing-library/jest-dom": "^5.16.2",
    "@testing-library/react": "13.0.0",
    "@testing-library/react-hooks": "7.0.2",
    "@testing-library/user-event": "^14.0.0-beta",
    "@tsconfig/docusaurus": "^1.0.4",
    "@types/cookie-parser": "^1.4.2",
    "@types/cypress": "^1.1.3",
    "@types/eventsource": "^1.1.8",
    "@types/express": "4.17.13",
    "@types/jest": "^27.4.1",
    "@types/json2csv": "^5.0.3",
    "@types/node": "^16.10.3",
    "@types/node-schedule": "^1.3.2",
    "@types/nodemailer": "^6.4.4",
    "@types/react": "17.0.15",
    "@types/react-dom": "17.0.15",
    "@types/react-table": "^7.7.10",
    "@types/sortablejs": "^1.10.7",
    "@types/supertest": "^2.0.12",
    "@types/webpack-env": "^1.16.3",
    "@types/ws": "^8.5.2",
    "@typescript-eslint/eslint-plugin": "5.18.0",
    "@typescript-eslint/parser": "5.18.0",
    "babel-loader": "8.1.0",
    "chromatic": "^6.5.1",
    "cross-env": "^7.0.3",
    "cypress": "^9.5.1",
    "dotenv": "^10.0.0",
    "dotenv-cli": "^4.1.1",
    "esbuild-loader": "^2.18.0",
    "eslint": "8.12.0",
    "eslint-config-next": "12.1.2",
    "eslint-config-prettier": "8.1.0",
    "eslint-plugin-cypress": "^2.10.3",
    "eslint-plugin-import": "2.26.0",
    "eslint-plugin-jsx-a11y": "6.4.1",
    "eslint-plugin-react": "7.29.4",
    "eslint-plugin-react-hooks": "4.4.0",
    "jest": "27.2.3",
    "jest-ts-auto-mock": "^2.1.0",
    "move-cli": "^2.0.0",
    "msw-storybook-addon": "^1.6.3",
    "nx": "13.9.7",
    "prettier": "2.5.1",
    "react-test-renderer": "17.0.2",
    "rimraf": "^3.0.2",
    "supertest": "^6.2.3",
    "ts-auto-mock": "^3.5.0",
    "ts-jest": "27.0.5",
    "ts-node-dev": "^1.1.8",
    "tsconfig-paths": "^3.11.0",
    "ttypescript": "^1.5.13",
    "typescript": "^4.3.5",
    "url-loader": "^3.0.0",
    "webpack": "^5.67.0"
  },
  "resolutions": {
    "@types/react": "17.0.2",
    "@types/react-dom": "17.0.2"
  },
  "packageManager": "yarn@1.22.15",
  "msw": {
    "workerDirectory": "public"
  }
}

I've also checked that all relevant folders are owned by me.

jaysoo commented 2 years ago

Are you able to nx migrate latest?

Is this repo publicly available? Does it work on other OS, like on a Mac?

anthonyma94 commented 2 years ago

I ended up installing a fresh VM of Ubuntu and that fixed the problem for now, will close the issue. Thank you for everyone's help.

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.