nx: Nx postinstall script fails in Github Actions if repo has nx/playwright

Current Behavior

Cannot install package sin Github Actions, so applications can’t build or deploy.

Expected Behavior

That pnpm install installs packages and postinstall scripts run without failure.

GitHub Repo

supernaut/nx18-next-playwright

Steps to Reproduce

  1. Add playwright to a Nx 18 repo.
  2. Push to Github with an action installning npm packages.

Nx Report

Node   : 20.11.0
   OS     : darwin-arm64
   pnpm   : 8.15.2

   nx                 : 18.0.4
   @nx/js             : 18.0.4
   @nx/jest           : 18.0.4
   @nx/linter         : 18.0.4
   @nx/eslint         : 18.0.4
   @nx/workspace      : 18.0.4
   @nx/cypress        : 18.0.4
   @nx/devkit         : 18.0.4
   @nx/esbuild        : 18.0.4
   @nx/eslint-plugin  : 18.0.4
   @nx/next           : 18.0.4
   @nx/node           : 18.0.4
   @nx/playwright     : 18.0.4
   @nx/plugin         : 18.0.4
   @nx/react          : 18.0.4
   @nx/storybook      : 18.0.4
   @nrwl/tao          : 18.0.4
   @nx/vite           : 18.0.4
   @nx/web            : 18.0.4
   @nx/webpack        : 18.0.4
   typescript         : 5.3.3
   ---------------------------------------
   Community plugins:
   nx-stylelint : 17.1.4

Failure Logs

.../node_modules/nx postinstall: Unable to create nodes for pnpm-lock.yaml using plugin nx/js/dependencies-and-lockfile. 
.../node_modules/nx postinstall: 	 Inner Error: Error: Could not find ".modules.yaml" at "/home/runner/work/project/project/node_modules/.modules.yaml"
.../node_modules/nx postinstall:     at loadPnpmHoistedDepsDefinition (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/plugins/js/lock-file/utils/pnpm-normalizer.js:23:15)
.../node_modules/nx postinstall:     at getNodes (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/plugins/js/lock-file/pnpm-parser.js:69:77)
.../node_modules/nx postinstall:     at getPnpmLockfileNodes (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/plugins/js/lock-file/pnpm-parser.js:27:12)
.../node_modules/nx postinstall:     at getLockFileNodes (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/plugins/js/lock-file/lock-file.js:36:59)
.../node_modules/nx postinstall:     at exports.createNodes (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/plugins/js/index.js:42:64)
.../node_modules/nx postinstall:     at buildProjectsConfigurationsFromProjectPathsAndPlugins (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:148:29)
.../node_modules/nx postinstall:     at createProjectConfigurations (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/utils/retrieve-workspace-files.js:89:156)
.../node_modules/nx postinstall:     at _retrieveProjectConfigurations (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/utils/retrieve-workspace-files.js:61:12)
.../node_modules/nx postinstall:     at retrieveProjectConfigurations (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/utils/retrieve-workspace-files.js:46:12)
.../node_modules/nx postinstall:     at async buildProjectGraphAndSourceMapsWithoutDaemon (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/project-graph.js:71:69)
.../node_modules/nx postinstall: Unable to create nodes for apps/next-app/playwright.config.ts using plugin @nx/playwright/plugin. 
.../node_modules/nx postinstall: 	 Inner Error: Error: ENOENT: no such file or directory, scandir 'apps/next-app'
.../node_modules/nx postinstall:     at readdirSync (node:fs:1515:26)
.../node_modules/nx postinstall:     at exports.createNodes (/home/runner/work/project/project/node_modules/.pnpm/@nx+playwright@18.0.4_@playwright+test@1.41.2_@swc-node+register@1.8.0_@swc+core@1.3.107_@typ_3om4g7g466ngcx6j4dyl6hei2y/node_modules/@nx/playwright/src/plugins/plugin.js:33:51)
.../node_modules/nx postinstall:     at buildProjectsConfigurationsFromProjectPathsAndPlugins (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:148:29)
.../node_modules/nx postinstall:     at createProjectConfigurations (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/utils/retrieve-workspace-files.js:89:156)
.../node_modules/nx postinstall:     at _retrieveProjectConfigurations (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/utils/retrieve-workspace-files.js:61:12)
.../node_modules/nx postinstall:     at retrieveProjectConfigurations (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/utils/retrieve-workspace-files.js:46:12)
.../node_modules/nx postinstall:     at async buildProjectGraphAndSourceMapsWithoutDaemon (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/project-graph.js:71:69)
.../node_modules/nx postinstall: /home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:156
.../node_modules/nx postinstall:                             throw new CreateNodesError(`Unable to create nodes for ${file} using plugin ${plugin.name}.`, e);
.../node_modules/nx postinstall:                                   ^
.../node_modules/nx postinstall: CreateNodesError: Unable to create nodes for apps/next-app/playwright.config.ts using plugin @nx/playwright/plugin. 
.../node_modules/nx postinstall: 	 Inner Error: Error: ENOENT: no such file or directory, scandir 'apps/next-app'
.../node_modules/nx postinstall:     at readdirSync (node:fs:1515:26)
.../node_modules/nx postinstall:     at exports.createNodes (/home/runner/work/project/project/node_modules/.pnpm/@nx+playwright@18.0.4_@playwright+test@1.41.2_@swc-node+register@1.8.0_@swc+core@1.3.107_@typ_3om4g7g466ngcx6j4dyl6hei2y/node_modules/@nx/playwright/src/plugins/plugin.js:33:51)
.../node_modules/nx postinstall:     at buildProjectsConfigurationsFromProjectPathsAndPlugins (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:148:29)
.../node_modules/nx postinstall:     at createProjectConfigurations (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/utils/retrieve-workspace-files.js:89:156)
.../node_modules/nx postinstall:     at _retrieveProjectConfigurations (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/utils/retrieve-workspace-files.js:61:12)
.../node_modules/nx postinstall:     at retrieveProjectConfigurations (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/utils/retrieve-workspace-files.js:46:12)
.../node_modules/nx postinstall:     at async buildProjectGraphAndSourceMapsWithoutDaemon (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/project-graph.js:71:69)
.../node_modules/nx postinstall:     at /home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:156:35
.../node_modules/nx postinstall:     at async Promise.all (index 0) {
.../node_modules/nx postinstall:   [cause]: Error: ENOENT: no such file or directory, scandir 'apps/next-app'
.../node_modules/nx postinstall:       at readdirSync (node:fs:1515:26)
.../node_modules/nx postinstall:       at exports.createNodes (/home/runner/work/project/project/node_modules/.pnpm/@nx+playwright@18.0.4_@playwright+test@1.41.2_@swc-node+register@1.8.0_@swc+core@1.3.107_@typ_3om4g7g466ngcx6j4dyl6hei2y/node_modules/@nx/playwright/src/plugins/plugin.js:33:51)
.../node_modules/nx postinstall:       at buildProjectsConfigurationsFromProjectPathsAndPlugins (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:148:29)
.../node_modules/nx postinstall:       at createProjectConfigurations (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/utils/retrieve-workspace-files.js:89:156)
.../node_modules/nx postinstall:       at _retrieveProjectConfigurations (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/utils/retrieve-workspace-files.js:61:12)
.../node_modules/nx postinstall:       at retrieveProjectConfigurations (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/utils/retrieve-workspace-files.js:46:12)
.../node_modules/nx postinstall:       at async buildProjectGraphAndSourceMapsWithoutDaemon (/home/runner/work/project/project/node_modules/.pnpm/nx@18.0.4_@swc-node+register@1.8.0_@swc+core@1.3.107/node_modules/nx/src/project-graph/project-graph.js:71:69) {
.../node_modules/nx postinstall:     errno: -2,
.../node_modules/nx postinstall:     code: 'ENOENT',
.../node_modules/nx postinstall:     syscall: 'scandir',
.../node_modules/nx postinstall:     path: 'apps/next-app'
.../node_modules/nx postinstall:   }
.../node_modules/nx postinstall: }
.../node_modules/nx postinstall: Node.js v20.11.0
.../node_modules/nx postinstall: Failed
 ELIFECYCLE  Command failed with exit code 1.
Error: Process completed with exit code 1.

Package Manager Version

pnpm 8.15.1

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

Nx report is run on my local machine, so it’s entirely correct. It works locally, but not in Github Actions running on ubuntu-latest. Will set up a repo to reproduce ASAP, but this is a critical showstopper.

About this issue

  • Original URL
  • State: open
  • Created 5 months ago
  • Reactions: 13
  • Comments: 26

Most upvoted comments

I seem to encounter the same error, besides that I fail to attribute the error to adding the testing library because I had Playwright bundled in the scaffolding process. Thanks for pointing that out.

Nx 18.0.5 seems to have fixed the issue in our production repository, but not in my test repo strangely enough. https://github.com/supernaut/nx18-next-playwright/actions/runs/8037651724/job/21952716499

I am using Gitlab CI and I am seeing the same behaviour. It’s quite a major issue for us because the entire point we want to use the plugin is for automatic E2E task splitting in CI environments.

I have the same issue in Vercel deployment running nx 18.0.8 but without playwright in my repo (installed cypress but still not used it). Localy it passes through this step normally

../node_modules/nx postinstall: Unable to create nodes for pnpm-lock.yaml using plugin nx/js/dependencies-and-lockfile. 
.../node_modules/nx postinstall: 	 Inner Error: Error: Could not find ".modules.yaml" at "/vercel/path0/node_modules/.modules.yaml"
.../node_modules/nx postinstall:     at loadPnpmHoistedDepsDefinition (/vercel/path0/node_modules/.pnpm/nx@18.0.8_@swc-node+register@1.8.0_@swc+core@1.3.100/node_modules/nx/src/plugins/js/lock-file/utils/pnpm-normalizer.js:23:15)
.../node_modules/nx postinstall:     at getNodes (/vercel/path0/node_modules/.pnpm/nx@18.0.8_@swc-node+register@1.8.0_@swc+core@1.3.100/node_modules/nx/src/plugins/js/lock-file/pnpm-parser.js:69:77)
.../node_modules/nx postinstall:     at getPnpmLockfileNodes (/vercel/path0/node_modules/.pnpm/nx@18.0.8_@swc-node+register@1.8.0_@swc+core@1.3.100/node_modules/nx/src/plugins/js/lock-file/pnpm-parser.js:27:12)
.../node_modules/nx postinstall:     at getLockFileNodes (/vercel/path0/node_modules/.pnpm/nx@18.0.8_@swc-node+register@1.8.0_@swc+core@1.3.100/node_modules/nx/src/plugins/js/lock-file/lock-file.js:36:59)
.../node_modules/nx postinstall:     at exports.createNodes (/vercel/path0/node_modules/.pnpm/nx@18.0.8_@swc-node+register@1.8.0_@swc+core@1.3.100/node_modules/nx/src/plugins/js/index.js:42:64)
.../node_modules/nx postinstall:     at buildProjectsConfigurationsFromProjectPathsAndPlugins (/vercel/path0/node_modules/.pnpm/nx@18.0.8_@swc-node+register@1.8.0_@swc+core@1.3.100/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:148:29)
.../node_modules/nx postinstall:     at createProjectConfigurations (/vercel/path0/node_modules/.pnpm/nx@18.0.8_@swc-node+register@1.8.0_@swc+core@1.3.100/node_modules/nx/src/project-graph/utils/retrieve-workspace-files.js:89:156)
.../node_modules/nx postinstall:     at _retrieveProjectConfigurations (/vercel/path0/node_modules/.pnpm/nx@18.0.8_@swc-node+register@1.8.0_@swc+core@1.3.100/node_modules/nx/src/project-graph/utils/retrieve-workspace-files.js:61:12)
.../node_modules/nx postinstall:     at retrieveProjectConfigurations (/vercel/path0/node_modules/.pnpm/nx@18.0.8_@swc-node+register@1.8.0_@swc+core@1.3.100/node_modules/nx/src/project-graph/utils/retrieve-workspace-files.js:46:12)
.../node_modules/nx postinstall:     at async buildProjectGraphAndSourceMapsWithoutDaemon (/vercel/path0/node_modules/.pnpm/nx@18.0.8_@swc-node+register@1.8.0_@swc+core@1.3.100/node_modules/nx/src/project-graph/project-graph.js:71:69)

same here. we have anagular monorepo (latest version - 1) run

// powershell windows
 >  NX   Unable to create nodes for pnpm-lock.yaml using plugin nx/js/dependencies-and-lockfile.
 
         Inner Error: Error: Could not find ".modules.yaml" at "C:\Users\XXXX\projects\XXXX/node_modules/.modules.yaml"

I got the same error, trying to drop node_modules and pnpm-lock.yaml on the local machine resulted in the presence of the error on my local machine too. A temporary fix seems to be touching the node_modules/.modules.yaml file before running the installation of any packages. An example follows

mkdir node_modules -p && touch node_modules/.modules.yaml
pnpm install --frozen-lockfile

Notice that at least in my case this fix was not enough as the plugin seems not to find my playwright configuration.

EDIT:

After a few trial and errors my fully workaround solution with playwright (to run both on local system and CI) is as follows:

# Workaround step 1: Create the missing yaml file 
mkdir node_modules -p && touch node_modules/.modules.yaml

# Install your dependencies how you prefer, notice that the --ignore-scripts is required 
# to complete the installation successfully
pnpm install --frozen-lockfile --ignore-scripts

# Workaround step 2: Install missing 3rdy party binaries like playwright's
pnpm exec playwright install-deps
pnpm exec playwright install

I updated to 18.0.5 but the install still breaks

// azure pipeline
...
node_modules/nx postinstall$ node ./bin/post-install
.../builder/node_modules/nx postinstall$ node ./bin/post-install
.../builder/node_modules/nx postinstall: Done
node_modules/nx postinstall: Unable to create nodes for pnpm-lock.yaml using plugin nx/js/dependencies-and-lockfile. 
node_modules/nx postinstall: 	 Inner Error: Error: Could not find ".modules.yaml" at "D:\a\1\s/node_modules/.modules.yaml"
node_modules/nx postinstall:     at loadPnpmHoistedDepsDefinition (D:\a\1\s\node_modules\nx\src\plugins\js\lock-file\utils\pnpm-normalizer.js:23:15)
node_modules/nx postinstall:     at getNodes (D:\a\1\s\node_modules\nx\src\plugins\js\lock-file\pnpm-parser.js:69:77)
node_modules/nx postinstall:     at getPnpmLockfileNodes (D:\a\1\s\node_modules\nx\src\plugins\js\lock-file\pnpm-parser.js:27:12)
node_modules/nx postinstall:     at getLockFileNodes (D:\a\1\s\node_modules\nx\src\plugins\js\lock-file\lock-file.js:36:59)
node_modules/nx postinstall:     at exports.createNodes (D:\a\1\s\node_modules\nx\src\plugins\js\index.js:42:64)
node_modules/nx postinstall:     at buildProjectsConfigurationsFromProjectPathsAndPlugins (D:\a\1\s\node_modules\nx\src\project-graph\utils\project-configuration-utils.js:148:29)
node_modules/nx postinstall:     at createProjectConfigurations (D:\a\1\s\node_modules\nx\src\project-graph\utils\retrieve-workspace-files.js:89:156)
node_modules/nx postinstall:     at _retrieveProjectConfigurations (D:\a\1\s\node_modules\nx\src\project-graph\utils\retrieve-workspace-files.js:61:12)
node_modules/nx postinstall:     at retrieveProjectConfigurations (D:\a\1\s\node_modules\nx\src\project-graph\utils\retrieve-workspace-files.js:46:12)
node_modules/nx postinstall:     at async buildProjectGraphAndSourceMapsWithoutDaemon (D:\a\1\s\node_modules\nx\src\project-graph\project-graph.js:71:69)
node_modules/nx postinstall: Done

Done in 2m 29.9s
Finishing: pnpm install and build dev Mode

Added repository that reproduces the issue. Direct link to failing run: https://github.com/supernaut/nx18-next-playwright/actions/runs/7917010202/job/21612157572

I was having this same error Unable to create nodes for pnpm-lock.yaml using plugin nx/js/dependencies-and-lockfile. among other errors similar to @srslafazan errors above, even after upgrading to nx@18.0.5.

I was able to get pass the error using --ignore-scripts with pnpm install as suggested by @JoelDigbeu . I still believe this is a workaround since it just ignores running the pre-install and post-install scripts.

- name: Install dependencies
   run: pnpm install --ignore-scripts