nx
nx copied to clipboard
Error using PNPM when creating workspace with stack
Current Behavior
Description
When creating a workspace using pnpx create-nx-workspace@latest (or pnpx create-nx-workspace) and choosing a stack (react, angular, or node) the installation fails. The installation completes when no "stack" has been selected. This has been test using an assortment of configurations.
Error message
This is the same error message all failing installations log to the terminal:
✔ Installing dependencies with pnpm
✖ Creating your workspace in nodepnpx
> NX Failed to create a workspace.
Error: npm ERR! Cannot read properties of null (reading 'matches')
npm ERR! A complete log of this run can be found in: /Users/XXXX/.npm/_logs/2023-06-16T22_48_07_306Z-debug-0.log
ERROR Command failed with exit code 1: create-nx-workspace nodepnpx
pnpm: Command failed with exit code 1: create-nx-workspace nodepnpx
at makeError (/opt/homebrew/Cellar/pnpm/8.6.2/libexec/dist/pnpm.cjs:24241:17)
at handlePromise (/opt/homebrew/Cellar/pnpm/8.6.2/libexec/dist/pnpm.cjs:24812:33)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.handler [as dlx] (/opt/homebrew/Cellar/pnpm/8.6.2/libexec/dist/pnpm.cjs:207055:7)
at async /opt/homebrew/Cellar/pnpm/8.6.2/libexec/dist/pnpm.cjs:216461:21
at async main (/opt/homebrew/Cellar/pnpm/8.6.2/libexec/dist/pnpm.cjs:216428:34)
at async runPnpm (/opt/homebrew/Cellar/pnpm/8.6.2/libexec/dist/pnpm.cjs:216683:5)
at async /opt/homebrew/Cellar/pnpm/8.6.2/libexec/dist/pnpm.cjs:216675:7
Installations tested
React
> pnpx create-nx-workspace@latest reactpnpx
✔ Which stack do you want to use? · react
✔ What framework would you like to use? · none
✔ Standalone project or integrated monorepo? · integrated
✔ Application name · reactpnpx
✔ Which bundler would you like to use? · vite
✔ Default stylesheet format · css
✔ Enable distributed caching to make your CI faster · No
Next.js
> pnpx create-nx-workspace@latest nextpnpx
✔ Which stack do you want to use? · react
✔ What framework would you like to use? · nextjs
✔ Standalone project or integrated monorepo? · integrated
✔ Application name · nextpnpx
✔ Would you like to use the App Router (recommended)? · Yes
✔ Default stylesheet format · css
✔ Enable distributed caching to make your CI faster · No
Express
> pnpx create-nx-workspace@latest nodepnpx
✔ Which stack do you want to use? · node
✔ What framework should be used? · express
✔ Standalone project or integrated monorepo? · standalone
✔ Would you like to generate a Dockerfile? [https://docs.docker.com/] · No
✔ Enable distributed caching to make your CI faster · No
Angular
> pnpx create-nx-workspace@latest angularpnpx
✔ Which stack do you want to use? · angular
✔ Standalone project or integrated monorepo? · standalone
✔ Default stylesheet format · css
✔ Would you like to use Standalone Components in your application? · Yes
✔ Would you like to add routing? · Yes
✔ Enable distributed caching to make your CI faster · No
Expected Behavior
Installation should complete without any errors, the same as NPM
npx create-nx-workspace
GitHub Repo
No response
Steps to Reproduce
Nx Report
Node : 18.12.1
OS : darwin arm64
npm : 8.19.2
Hasher : Native
nx : 16.3.2
@nx/js : 16.3.2
@nx/jest : 16.3.2
@nx/linter : 16.3.2
@nx/workspace : 16.3.2
@nx/devkit : 16.3.2
@nx/node : 16.3.2
@nrwl/tao : 16.3.2
typescript : 5.1.3
Failure Logs
248 silly placeDep ROOT [email protected] OK for: @nodepnpx/[email protected] want: ^29.4.1
249 timing idealTree Completed in 9651ms
250 timing command:install Completed in 9655ms
251 verbose stack TypeError: Cannot read properties of null (reading 'matches')
251 verbose stack at Link.matches (/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:1115:41)
251 verbose stack at Link.canDedupe (/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:1069:15)
251 verbose stack at PlaceDep.pruneDedupable (/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:426:14)
251 verbose stack at new PlaceDep (/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:278:14)
251 verbose stack at #buildDepStep (/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:933:18)
251 verbose stack at async Arborist.buildIdealTree (/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:196:7)
251 verbose stack at async Promise.all (index 1)
251 verbose stack at async Arborist.reify (/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:159:5)
251 verbose stack at async Install.exec (/opt/homebrew/lib/node_modules/npm/lib/commands/install.js:148:5)
251 verbose stack at async module.exports (/opt/homebrew/lib/node_modules/npm/lib/cli-entry.js:61:5)
Operating System
- [X] macOS
- [ ] Linux
- [ ] Windows
- [ ] Other (Please specify)
Additional Information
The installation process works fine with NPM
npx create-nx-workspace@latest
Hey :) I can't reproduce this following the steps you provided.
The nx report on the workspace I created is:
> NX Report complete - copy this into the issue template
Node : 18.14.0
OS : darwin x64
pnpm : 8.3.1
Hasher : Native
nx : 16.3.2
@nx/js : 16.3.2
@nx/jest : 16.3.2
@nx/linter : 16.3.2
@nx/workspace : 16.3.2
@nx/cypress : 16.3.2
@nx/eslint-plugin : 16.3.2
@nx/next : 16.3.2
@nx/react : 16.3.2
typescript : 5.0.2
Can you check the version of your pnpm installation?
Also, it may be worth running pnpm store prune as an additional step to see if this helps remove any potential env issues.
Hi, @Coly010.
I rand pnpm store prune and I tried both 8.6.3 and 7.33.1 pnpm versions. If I run pnpm install after the install error everything seems to work.
But if I run npm install after using pnpx create-nx-workspace I get that same error in the system console I posted above.
TypeError: Cannot read properties of null (reading 'matches')
It seems the install process is using npm instead. The file that triggers the error is coming from the npm CLI.
/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:1115:41
Just tested this with the last Nx v17 and this issue seems to be sorted
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏
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.