Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nx-ignore fails with cryptic message #80

Open
mrlubos opened this issue Jun 27, 2022 · 4 comments
Open

nx-ignore fails with cryptic message #80

mrlubos opened this issue Jun 27, 2022 · 4 comments
Assignees

Comments

@mrlubos
Copy link

mrlubos commented Jun 27, 2022

Hey! For context, I am working with Vercel, Doppler, and Nx and I am trying to deploy a project from monorepo. After adding npx nx-ignore project to the ignore command, my previews stop working. Removing this command fixes the issue, but obviously removes the benefit of skipping building certain projects.

The problem is that it's not obvious why my build doesn't complete when using npx nx-ignore project? Is anyone able to offer any pointers based on the logs I receive? My best guesses are I need to upgrade Nx to v14 (nx-ignore is v14.2.0), move TypeScript from devDependencies to dependencies (unlikely?), or something else. Any hints?

[14:54:48.500] Cloning github.com/<org>/<project> (Branch: feature, Commit: 0000000)
[14:54:49.362] Cloning completed: 862.112ms
[14:54:49.362] Running "npx nx-ignore project"
[14:54:58.113] ≫ Using Nx to determine if this project (project) is affected by the commit...
[14:55:00.112] ✅ - Build can proceed since project is affected
[14:55:00.988] Installing build runtime...
[14:55:02.904] Build runtime installed: 1.916s
[14:55:03.535] Looking up build cache...
[14:55:03.983] Build Cache not found
[14:55:04.114] Installing dependencies...
[14:55:04.443] yarn install v1.22.17
[14:55:04.563] [1/4] Resolving packages...
[14:55:05.412] [2/4] Fetching packages...
[14:55:05.433] warning Pattern ["@storybook/react-docgen-typescript-plugin@canary"] is trying to unpack in the same destination "/vercel/.cache/yarn/v6/npm-@storybook-react-docgen-typescript-plugin-1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0-3103532ff494fb7dc3cf835f10740ecf6a26c0f9-integrity/node_modules/@storybook/react-docgen-typescript-plugin" as pattern ["@storybook/react-docgen-typescript-plugin@1.0.2-canary.6.9d540b91e815f8fc2f8829189deb00553559ff63.0"]. This could result in non-deterministic behavior, skipping.
[14:55:54.358] [3/4] Linking dependencies...
[14:55:54.364] warning " > @craco/craco@6.4.3" has incorrect peer dependency "react-scripts@^4.0.0".
[14:55:54.367] warning " > @storybook/addon-knobs@6.4.0" has unmet peer dependency "@storybook/api@^6.4.0".
[14:55:54.367] warning " > @storybook/addon-knobs@6.4.0" has unmet peer dependency "@storybook/components@^6.4.0".
[14:55:54.367] warning " > @storybook/addon-knobs@6.4.0" has unmet peer dependency "@storybook/core-events@^6.4.0".
[14:55:54.367] warning " > @storybook/addon-knobs@6.4.0" has unmet peer dependency "@storybook/theming@^6.4.0".
[14:55:54.369] warning " > @storybook/react@6.5.4" has unmet peer dependency "require-from-string@^2.0.2".
[14:55:54.378] warning "craco-less > less-loader@7.3.0" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
[14:55:54.380] warning "theme-ui > @theme-ui/mdx@0.14.5" has unmet peer dependency "@mdx-js/react@^1 || ^2".
[14:55:54.385] warning "@nrwl/cypress > @cypress/webpack-preprocessor@5.11.1" has unmet peer dependency "babel-loader@^8.0.2".
[14:55:54.385] warning "@nrwl/cypress > @cypress/webpack-preprocessor@5.11.1" has unmet peer dependency "webpack@^4 || ^5".
[14:55:54.385] warning "@nrwl/cypress > @nrwl/devkit@13.10.5" has unmet peer dependency "nx@>= 13.10 <= 15".
[14:55:54.385] warning "@nrwl/cypress > ts-loader@9.2.7" has unmet peer dependency "webpack@^5.0.0".
[14:55:54.386] warning " > @nrwl/eslint-plugin-nx@13.10.5" has incorrect peer dependency "@typescript-eslint/parser@~5.18.0".
[14:55:54.392] warning " > @storybook/preset-create-react-app@4.1.2" has unmet peer dependency "@storybook/node-logger@*".
[14:55:54.393] warning " > @testing-library/user-event@14.2.0" has unmet peer dependency "@testing-library/dom@>=7.21.4".
[14:55:54.395] warning "react-scripts > tailwindcss@3.0.23" has unmet peer dependency "autoprefixer@^10.0.2".
[14:55:54.396] warning "react-scripts > eslint-config-react-app > eslint-plugin-flowtype@8.0.3" has unmet peer dependency "@babel/plugin-syntax-flow@^7.14.5".
[14:55:54.396] warning "react-scripts > eslint-config-react-app > eslint-plugin-flowtype@8.0.3" has unmet peer dependency "@babel/plugin-transform-react-jsx@^7.14.9".
[14:55:54.504] warning Workspaces can only be enabled in private projects.
[14:58:10.040] [4/4] Building fresh packages...
[14:58:39.771] $ husky install
[14:58:39.843] husky - Git hooks installed
[14:58:39.846] Done in 215.41s.
[14:58:40.829] nx run [project][:target][:configuration] [_..]
[14:58:40.830] 
[14:58:40.830] Run a target for a project
[14:58:40.830]     (e.g., nx run myapp:serve:production).
[14:58:40.830] 
[14:58:40.830]     You can also use the infix notation to run a target:
[14:58:40.830]     (e.g., nx serve myapp --configuration=production)
[14:58:40.830] 
[14:58:40.830]     You can skip the use of Nx cache by using the --skip-nx-cache option.
[14:58:40.830] 
[14:58:40.831] Options:
[14:58:40.831]       --version        Show version number  [boolean]
[14:58:40.831]       --prod           Use the production configuration  [boolean] [default: false]
[14:58:40.831]   -c, --configuration  Target configuration  [string]
[14:58:40.831]       --project        Target project  [string]
[14:58:40.831] 
[14:58:40.833] {
[14:58:40.833]   stack: "Error: Cannot find module 'typescript'\n" +
[14:58:40.833]     'Require stack:\n' +
[14:58:40.833]     '- /vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/typescript-import-locator.js\n' +
[14:58:40.833]     '- /vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/explicit-project-dependencies.js\n' +
[14:58:40.833]     '- /vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/index.js\n' +
[14:58:40.833]     '- /vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-project-graph.js\n' +
[14:58:40.833]     '- /vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/daemon/server/project-graph-incremental-recomputation.js\n' +
[14:58:40.834]     '- /vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/daemon/server/server.js\n' +
[14:58:40.834]     '- /vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/daemon/server/start.js\n' +
[14:58:40.834]     '    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)\n' +
[14:58:40.834]     '    at Function.Module._load (internal/modules/cjs/loader.js:746:27)\n' +
[14:58:40.834]     '    at Module.require (internal/modules/cjs/loader.js:974:19)\n' +
[14:58:40.834]     '    at require (internal/modules/cjs/helpers.js:101:18)\n' +
[14:58:40.834]     '    at new TypeScriptImportLocator (/vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/typescript-import-locator.js:11:20)\n' +
[14:58:40.835]     '    at buildExplicitTypeScriptDependencies (/vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/explicit-project-dependencies.js:7:27)\n' +
[14:58:40.835]     '    at buildExplicitTypescriptAndPackageJsonDependencies (/vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/build-explicit-typescript-and-package-json-dependencies.js:10:98)\n' +
[14:58:40.835]     '    at buildExplicitDependenciesWithoutWorkers (/vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-project-graph.js:149:117)\n' +
[14:58:40.835]     '    at buildExplicitDependencies (/vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-project-graph.js:106:16)\n' +
[14:58:40.835]     '    at /vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-project-graph.js:85:15',
[14:58:40.835]   message: "Cannot find module 'typescript'\n" +
[14:58:40.835]     'Require stack:\n' +
[14:58:40.835]     '- /vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/typescript-import-locator.js\n' +
[14:58:40.835]     '- /vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/explicit-project-dependencies.js\n' +
[14:58:40.835]     '- /vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/index.js\n' +
[14:58:40.835]     '- /vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-project-graph.js\n' +
[14:58:40.835]     '- /vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/daemon/server/project-graph-incremental-recomputation.js\n' +
[14:58:40.835]     '- /vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/daemon/server/server.js\n' +
[14:58:40.836]     '- /vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/daemon/server/start.js\n' +
[14:58:40.836]     '\n' +
[14:58:40.836]     'Because of the error the Nx daemon process has exited. The next Nx command is going to restart the daemon process.\n' +
[14:58:40.836]     'If the error persists, please run "nx reset".',
[14:58:40.836]   code: 'MODULE_NOT_FOUND',
[14:58:40.836]   requireStack: [
[14:58:40.836]     '/vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/typescript-import-locator.js',
[14:58:40.836]     '/vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/explicit-project-dependencies.js',
[14:58:40.836]     '/vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/index.js',
[14:58:40.836]     '/vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-project-graph.js',
[14:58:40.836]     '/vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/daemon/server/project-graph-incremental-recomputation.js',
[14:58:40.836]     '/vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/daemon/server/server.js',
[14:58:40.836]     '/vercel/.npm/_npx/237/lib/node_modules/nx-ignore/node_modules/nx/src/daemon/server/start.js'
[14:58:40.836]   ]
[14:58:40.836] }
[14:58:40.849] Error: Command "npx nx build project" exited with 1
@jaysoo jaysoo self-assigned this Aug 11, 2022
@jaysoo
Copy link
Member

jaysoo commented Aug 11, 2022

It looks like the location of where nx-ignore is installed is messing up the actual nx installation.

You can try adding nx-ignore as a devDependencies for now.

@mrlubos
Copy link
Author

mrlubos commented Aug 14, 2022

Hey @jaysoo, wanted to give you an update. I've upgraded to v14 and this error seems to be resolved. I would therefore attribute it to a mismatch between dependencies, but unfortunately cannot say for sure

@dallastjames
Copy link

dallastjames commented Aug 23, 2022

I've been running into this as well. I have a long-running NX workspace with several apps and libraries, primarily Angular/NestJS/TS based. I was wanting to play around with Next and Vercel for a potential new app. Created a new application using the schematics, set up everything according to the documentation, but as soon as I add nx-ignore to the vercel configuration I get failing builds with the same error as above whenever my application attempts to build using a vercel build cache. Retrying a build that fails with this error without the vercel build cache will succeed.

I've tried replicating this issue using a new workspace, but the issue does not seem to be present there, so perhaps something about this being an older upgraded workspace instead of a new one might have a factor? Prior to exploring nextjs, I upgraded my workspace to the latest v14 fwiw.

Build log output for a newly generated next application inside of my workspace.

[15:54:57.871] Cloning github.com/<org>/<repo> (Branch: main, Commit: 2d6f672)
[15:54:59.046] Cloning completed: 1.174s
[15:54:59.046] Running "npx nx-ignore blank-test"
[15:55:09.911] ≫ Using Nx to determine if this project (blank-test) is affected by the commit...
[15:55:11.947] ✅ - Build can proceed since blank-test is affected
[15:55:13.368] Looking up build cache...
[15:55:25.808] Build cache downloaded [227.37 MB]: 12059.577ms
[15:55:26.056] Running "vercel build"
[15:55:26.551] Vercel CLI 28.1.2
[15:55:27.380] Installing dependencies...
[15:55:32.552] 
[15:55:32.552] up to date in 5s
[15:55:32.552] 
[15:55:32.552] 271 packages are looking for funding
[15:55:32.552]   run `npm fund` for details
[15:55:32.568] Detected Next.js version: 12.2.5
[15:55:32.764] Running "npx nx build blank-test --prod"
[15:55:33.421] nx run [project][:target][:configuration] [_..]
[15:55:33.422] 
[15:55:33.422] Run a target for a project
[15:55:33.422]     (e.g., nx run myapp:serve:production).
[15:55:33.422] 
[15:55:33.422]     You can also use the infix notation to run a target:
[15:55:33.422]     (e.g., nx serve myapp --configuration=production)
[15:55:33.422] 
[15:55:33.423]     You can skip the use of Nx cache by using the --skip-nx-cache option.
[15:55:33.423] 
[15:55:33.423] Options:
[15:55:33.423]       --version           Show version number  [boolean]
[15:55:33.423]       --prod              Use the production configuration  [boolean] [default: false]
[15:55:33.423]   -c, --configuration     Target configuration  [string]
[15:55:33.424]       --project           Target project  [string]
[15:55:33.424]       --output-style      Defines how Nx emits outputs tasks logs  [string] [choices: "dynamic", "static", "stream", "stream-without-prefixes", "compact"]
[15:55:33.424]       --nx-bail           Stop command execution after the first failed task  [boolean] [default: false]
[15:55:33.424]       --nx-ignore-cycles  Ignore cycles in the task graph  [boolean] [default: false]
[15:55:33.424] 
[15:55:33.424] {
[15:55:33.424]   stack: "Error: Cannot find module 'typescript'\n" +
[15:55:33.425]     'Require stack:\n' +
[15:55:33.425]     '- /vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/typescript-import-locator.js\n' +
[15:55:33.425]     '- /vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/explicit-project-dependencies.js\n' +
[15:55:33.425]     '- /vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/index.js\n' +
[15:55:33.425]     '- /vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-project-graph.js\n' +
[15:55:33.425]     '- /vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/daemon/server/project-graph-incremental-recomputation.js\n' +
[15:55:33.425]     '- /vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/daemon/server/server.js\n' +
[15:55:33.426]     '- /vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/daemon/server/start.js\n' +
[15:55:33.426]     '    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)\n' +
[15:55:33.426]     '    at Function.Module._load (internal/modules/cjs/loader.js:746:27)\n' +
[15:55:33.426]     '    at Module.require (internal/modules/cjs/loader.js:974:19)\n' +
[15:55:33.427]     '    at require (internal/modules/cjs/helpers.js:101:18)\n' +
[15:55:33.427]     '    at new TypeScriptImportLocator (/vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/typescript-import-locator.js:11:20)\n' +
[15:55:33.427]     '    at buildExplicitTypeScriptDependencies (/vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/explicit-project-dependencies.js:7:27)\n' +
[15:55:33.427]     '    at buildExplicitTypescriptAndPackageJsonDependencies (/vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/build-explicit-typescript-and-package-json-dependencies.js:10:98)\n' +
[15:55:33.428]     '    at buildExplicitDependencies (/vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-project-graph.js:118:16)\n' +
[15:55:33.428]     '    at /vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-project-graph.js:83:15',
[15:55:33.429]   message: "Cannot find module 'typescript'\n" +
[15:55:33.429]     'Require stack:\n' +
[15:55:33.429]     '- /vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/typescript-import-locator.js\n' +
[15:55:33.429]     '- /vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/explicit-project-dependencies.js\n' +
[15:55:33.429]     '- /vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/index.js\n' +
[15:55:33.429]     '- /vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-project-graph.js\n' +
[15:55:33.429]     '- /vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/daemon/server/project-graph-incremental-recomputation.js\n' +
[15:55:33.429]     '- /vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/daemon/server/server.js\n' +
[15:55:33.430]     '- /vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/daemon/server/start.js\n' +
[15:55:33.430]     '\n' +
[15:55:33.430]     'Because of the error the Nx daemon process has exited. The next Nx command is going to restart the daemon process.\n' +
[15:55:33.430]     'If the error persists, please run "nx reset".',
[15:55:33.430]   code: 'MODULE_NOT_FOUND',
[15:55:33.430]   requireStack: [
[15:55:33.430]     '/vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/typescript-import-locator.js',
[15:55:33.430]     '/vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/explicit-project-dependencies.js',
[15:55:33.430]     '/vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-dependencies/index.js',
[15:55:33.431]     '/vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/project-graph/build-project-graph.js',
[15:55:33.431]     '/vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/daemon/server/project-graph-incremental-recomputation.js',
[15:55:33.431]     '/vercel/.npm/_npx/254/lib/node_modules/nx-ignore/node_modules/nx/src/daemon/server/start.js'
[15:55:33.431]   ]
[15:55:33.431] }
[15:55:33.435] Error! Command "npx nx build blank-test --prod" exited with 1

I'd love any suggestions about how to further debug this issue. 👍

@Kolahzary
Copy link

I'm seeing same error in my pipeline after upgrading nx to latest version today.
But it doesn't break the pipeline, just the error there is ugly

npm WARN exec The following package was not found and will be installed: nx-ignore@15.6.0
--
14:20:16.314 | ≫ Using Nx to determine if this project (frontend) is affected by the commit...
14:20:25.106 | npm WARN using --force Recommended protections disabled.
14:20:26.080 | Failed to process the project graph with "index". This will error in the future!
14:20:26.080 | Run with NX_VERBOSE_LOGGING=true to see the error.
14:20:26.309 | ✅ - Build can proceed since frontend is affected
14:20:56.994 | Restored build cache
14:20:57.040 | Running "vercel build"
14:20:57.480 | Vercel CLI 28.18.3
14:20:58.130 | > Detected Nx. Adjusting default settings...
14:20:58.483 | Detected `pnpm-lock.yaml` version 6 generated by pnpm 8...
14:20:58.486 | Running "install" command: `pnpm install`...
14:20:59.248 | Lockfile is up to date, resolution step is skipped
14:21:04.040 | Progress: resolved 1, reused 0, downloaded 0, added 0
14:21:04.373 | Packages: +721 -454

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants