asdf-nodejs
asdf-nodejs copied to clipboard
Can't list global packages on Node 16
Using asdf-nodejs (from master) on macOS, I'm seeing a problem with global packages starting in node 16.
This works fine:
asdf plugin install nodejs
asdf install nodejs 14.19.3
asdf global nodejs 14.19.3
npm list -g
But this fails:
asdf install nodejs 16.15.1
asdf global nodejs 16.15.1
npm list -g
Here's the error:
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path /Users/dave/.asdf/installs/nodejs/16.15.1/.npm
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, lstat '/Users/dave/.asdf/installs/nodejs/16.15.1/.npm'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/dave/.npm/_logs/2022-06-13T21_32_59_054Z-debug-0.log
And here's that log file:
0 verbose cli /Users/dave/.asdf/installs/nodejs/16.15.1/bin/node /Users/dave/.asdf/installs/nodejs/16.15.1/bin/npm
1 info using [email protected]
2 info using [email protected]
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:/Users/dave/.asdf/installs/nodejs/16.15.1/lib/node_modules/npm/npmrc Completed in 1ms
6 timing config:load:builtin Completed in 1ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 1ms
9 timing config:load:project Completed in 3ms
10 timing config:load:file:/Users/dave/.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:/Users/dave/.asdf/installs/nodejs/16.15.1/.npm/etc/npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:validate Completed in 0ms
15 timing config:load:credentials Completed in 1ms
16 timing config:load:setEnvs Completed in 1ms
17 timing config:load Completed in 9ms
18 timing npm:load:configload Completed in 9ms
19 timing npm:load:mkdirpcache Completed in 2ms
20 timing npm:load:mkdirplogs Completed in 1ms
21 verbose title npm list
22 verbose argv "list" "--location" "global"
23 timing npm:load:setTitle Completed in 13ms
24 timing config:load:flatten Completed in 1ms
25 timing npm:load:display Completed in 4ms
26 verbose logfile logs-max:10 dir:/Users/dave/.npm/_logs
27 verbose logfile /Users/dave/.npm/_logs/2022-06-13T21_32_59_054Z-debug-0.log
28 timing npm:load:logFile Completed in 3ms
29 timing npm:load:timers Completed in 0ms
30 timing npm:load:configScope Completed in 0ms
31 timing npm:load Completed in 32ms
32 timing arborist:ctor Completed in 0ms
33 silly logfile done cleaning log files
34 timing command:list Completed in 24ms
35 verbose stack Error: ENOENT: no such file or directory, lstat '/Users/dave/.asdf/installs/nodejs/16.15.1/.npm'
36 verbose cwd /Users/dave/.asdf/plugins/nodejs
37 verbose Darwin 21.5.0
38 verbose node v16.15.1
39 verbose npm v8.11.0
40 error code ENOENT
41 error syscall lstat
42 error path /Users/dave/.asdf/installs/nodejs/16.15.1/.npm
43 error errno -2
44 error enoent ENOENT: no such file or directory, lstat '/Users/dave/.asdf/installs/nodejs/16.15.1/.npm'
45 error enoent This is related to npm not being able to find a file.
45 error enoent
46 verbose exit -2
47 timing npm Completed in 105ms
48 verbose code -2
49 error A complete log of this run can be found in:
49 error /Users/dave/.npm/_logs/2022-06-13T21_32_59_054Z-debug-0.log
I can confirm: the referenced ~/.asdf/installs/nodejs/16.15.1/.npm
directory does not exist.
For what it's worth, I don't have this problem when I install node 16 with Homebrew, though I don't see any .npm
directory in that scenario. Node gets installed in /usr/local/opt/node@16
and globally installed packages go in /usr/local/lib/node_modules
, and I don't see a .npm
directory around either of those paths.
I'm currently having the same issue here, but with ubuntu 20.4
I had the same situation with 18.4.0, so I did this
mkdir -p ~/.asdf/installs/nodejs/18.4.0/.npm/lib
I believe installing any global package will also create the ~/.asdf/installs/nodejs/<current version>/.npm
directory. Running npm list -g
suggests at least one global package might have been expected, so the error actually provides a hint that the environment isn't in quite the desired state. Glass half-full 😄
The .npm
directory is not used by this plugin anymore. Just updating the plugin should solve the issue. Note that global packages will need to be installed again