I have node v15.14.0
and npm 7.8.0
on Arch Linux x86_64
(installed from that distro's repos).
Starting a project in an empty directory with npm init
and then trying to install something with npm i <blah>
always fails in the same fashion. An example, run in $HOME/tmp
:
$ npm i btoa
npm ERR! subset is not a function
npm ERR! A complete log of this run can be found in:
npm ERR! $HOME/.npm/_logs/2021-04-08T00_32_19_504Z-debug.log
That log file reads as follows:
0 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'i', 'btoa' ]
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:/usr/lib/node_modules/npm/npmrc Completed in 0ms
6 timing config:load:builtin Completed in 0ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:$HOME/tmp/.npmrc Completed in 0ms
10 timing config:load:project Completed in 1ms
11 timing config:load:file:$HOME/.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:/usr/etc/npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setEnvs Completed in 1ms
17 timing config:load Completed in 5ms
18 timing npm:load:configload Completed in 5ms
19 timing npm:load:setTitle Completed in 0ms
20 timing npm:load:setupLog Completed in 1ms
21 timing npm:load:cleanupLog Completed in 1ms
22 timing npm:load:configScope Completed in 1ms
23 timing npm:load:projectScope Completed in 0ms
24 timing npm:load Completed in 9ms
25 timing config:load:flatten Completed in 2ms
26 timing arborist:ctor Completed in 0ms
27 timing arborist:ctor Completed in 0ms
28 timing idealTree:init Completed in 13ms
29 timing idealTree:userRequests Completed in 3ms
30 silly idealTree buildDeps
31 silly fetch manifest btoa@*
32 http fetch GET 304 https://registry.npmjs.org/btoa 193ms (from cache)
33 silly placeDep ROOT [email protected] KEEP for: [email protected] want: *
34 timing idealTree:#root Completed in 198ms
35 timing idealTree:buildDeps Completed in 199ms
36 timing idealTree:fixDepFlags Completed in 0ms
37 timing idealTree Completed in 217ms
38 timing reify:loadTrees Completed in 217ms
39 timing reify:diffTrees Completed in 0ms
40 silly reify moves {}
41 timing reify:retireShallow Completed in 0ms
42 timing reify:createSparse Completed in 0ms
43 timing reify:loadBundles Completed in 0ms
44 timing reify:unpack Completed in 0ms
45 timing reify:unretire Completed in 0ms
46 timing build:queue Completed in 0ms
47 timing build:deps Completed in 1ms
48 timing build Completed in 1ms
49 timing reify:build Completed in 1ms
50 timing reify:trash Completed in 0ms
51 timing command:install Completed in 230ms
52 verbose stack TypeError: subset is not a function
52 verbose stack at Arborist.[saveIdealTree] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:956:37)
52 verbose stack at /usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:138:39
52 verbose stack at async Arborist.reify (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:134:5)
52 verbose stack at async Install.install (/usr/lib/node_modules/npm/lib/install.js:137:5)
53 verbose cwd $HOME/tmp
54 verbose Linux 5.10.25-1-lts
55 verbose argv "/usr/bin/node" "/usr/bin/npm" "i" "btoa"
56 verbose node v15.14.0
57 verbose npm v7.8.0
58 error subset is not a function
59 verbose exit 1
So you can see that
/usr/lib/node_modules
(where I can install just fine with sudo npm install -g
);subset
function seems to pop up when the install
command calls/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js
I've checked that that file defines
const {subset} = require('semver')
How do I fix this?
Edit:
This is to address a comment below: this subset
issue occurs regardless of what I try to install. btoa
was nothing but an example.
For those who miss papanito's comment
sudo npm i -g npm
Worked for me on Arch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With