CodeClimbersIO / cli

The cli for the project
MIT License
6 stars 6 forks source link

Bug: on global install, some get `cannot set properties of null (setting 'dev')` #175

Closed rphovley closed 3 weeks ago

rphovley commented 1 month ago

Replication Steps:

current workaround is to update npm (npm i -g npm) and rerun npm i -g codeclimbers. For reasons I haven't uncovered yet, this solves the issue (changelog between npm 10.8.1 and 10.8.2 don't have anything that seems relevant to the error)

Full Stack Trace:

0 verbose cli /usr/local/bin/node /usr/local/bin/npm
1 info using npm@10.8.1
2 info using node@v20.16.0
3 silly config load:file:/usr/local/lib/node_modules/npm/npmrc
4 silly config load:file:/Users/paulhovley/.npmrc
5 silly config load:file:/usr/local/etc/npmrc
6 verbose title npm i publishing-workspaces-test
7 verbose argv "i" "--global" "publishing-workspaces-test"
8 verbose logfile logs-max:10 dir:/Users/paulhovley/.npm/_logs/2024-08-16T00_22_40_359Z-
9 verbose logfile /Users/paulhovley/.npm/_logs/2024-08-16T00_22_40_359Z-debug-0.log
10 silly packumentCache heap:4345298944 maxSize:1086324736 maxEntrySize:543162368
11 silly logfile start cleaning logs, removing 1 files
12 silly logfile done cleaning log files
13 silly idealTree buildDeps
14 silly fetch manifest publishing-workspaces-test@*
15 silly packumentCache full:https://registry.npmjs.org/publishing-workspaces-test cache-miss
16 http fetch GET 200 https://registry.npmjs.org/publishing-workspaces-test 414ms (cache updated)
17 silly packumentCache full:https://registry.npmjs.org/publishing-workspaces-test set size:undefined disposed:false
18 silly placeDep ROOT publishing-workspaces-test@1.0.1 OK for:  want: *
19 silly fetch manifest @me/server@file:packages/server
20 silly placeDep node_modules/publishing-workspaces-test @me/server@ OK for: publishing-workspaces-test@1.0.1 want: file:packages/server
21 silly reify moves {}
22 silly tarball no local data for publishing-workspaces-test@https://registry.npmjs.org/publishing-workspaces-test/-/publishing-workspaces-test-1.0.1.tgz. Extracting by manifest.
23 http fetch GET 200 https://registry.npmjs.org/publishing-workspaces-test/-/publishing-workspaces-test-1.0.1.tgz 96ms (cache miss)
24 verbose stack TypeError: Cannot set properties of null (setting 'dev')
24 verbose stack     at calcDepFlagsStep (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:34:21)
24 verbose stack     at visit (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:12:20)
24 verbose stack     at visitNode (/usr/local/lib/node_modules/npm/node_modules/treeverse/lib/depth-descent.js:58:25)
24 verbose stack     at next (/usr/local/lib/node_modules/npm/node_modules/treeverse/lib/depth-descent.js:44:19)
24 verbose stack     at depth (/usr/local/lib/node_modules/npm/node_modules/treeverse/lib/depth-descent.js:83:10)
24 verbose stack     at depth (/usr/local/lib/node_modules/npm/node_modules/treeverse/lib/depth.js:27:12)
24 verbose stack     at calcDepFlags (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:10:15)
24 verbose stack     at Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:232:7)
24 verbose stack     at async Install.exec (/usr/local/lib/node_modules/npm/lib/commands/install.js:150:5)
24 verbose stack     at async Npm.exec (/usr/local/lib/node_modules/npm/lib/npm.js:207:9)
25 error Cannot set properties of null (setting 'dev')
26 silly unfinished npm timer reify 1723767760788
27 verbose cwd /usr/local/bin
28 verbose os Darwin 23.5.0
29 verbose node v20.16.0
30 verbose npm  v10.8.1
31 verbose exit 1
32 verbose code 1
33 error A complete log of this run can be found in: /Users/paulhovley/.npm/_logs/2024-08-16T00_22_40_359Z-debug-0.log
rphovley commented 1 month ago

Might have something to do with:

https://github.com/npm/cli/issues/4064#issuecomment-1142426287 https://github.com/npm/cli/issues/3847

EDIT: These are old but also seem to hint at setting symlinks correctly

rphovley commented 1 month ago

Some deeper looks seem to indicate that this file symlink is not working on the global install

24 verbose stack TypeError: Cannot set properties of null (setting 'dev')
24 verbose stack     at calcDepFlagsStep (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js:34:21)

The issue occurs in this code

  if (node.isLink) {
    node.target.dev = node.dev // node.target is null
    node.target.optional = node.optional
    node.target.devOptional = node.devOptional
    node.target.peer = node.peer
    return calcDepFlagsStep(node.target)
  }

This PR has some cleanup that makes better use of workspaces, but the end result has been the same with it that the internal file dependencies aren't working https://github.com/CodeClimbersIO/cli/pull/176/files

rphovley commented 1 month ago

Also, made a stackoverflow to see if we get any bites: Edits welcome https://stackoverflow.com/questions/78877405/title-npm-global-install-fails-for-monorepo-with-workspace-dependencies

And a minimally reproducable simple repo https://github.com/rphovley/publishing-workspaces-test