gpt4 book ai didi

node.js - npm 安装失败,出现 'subset is not a function'

转载 作者:行者123 更新时间:2023-12-03 20:23:07 25 4
gpt4 key购买 nike

我有 node v15.14.0npm 7.8.0Arch Linux x86_64 (从该发行版的存储库安装)。
使用 npm init 在空目录中启动项目然后尝试使用 npm i <blah> 安装一些东西总是以同样的方式失败。一个例子,在 $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
该日志文件内容如下:
0 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'i', 'btoa' ]
1 info using npm@7.8.0
2 info using node@v15.14.0
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 btoa@1.2.1 KEEP for: tmp@1.0.0 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
所以你可以看到
  • 我的“全局”模块位于 /usr/lib/node_modules (我可以用 sudo npm install -g 很好地安装);
  • subset函数似乎在 install 时弹出命令调用
  • /usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js
    我已经检查过该文件是否定义了
    const {subset} = require('semver')
    我该如何解决?
    编辑:
    这是为了解决下面的评论:this subset无论我尝试安装什么,都会出现问题。 btoa只不过是一个例子。

    最佳答案

    错过papanito's的 friend 评论

    sudo npm i -g npm
    在 Arch 上为我工作。

    关于node.js - npm 安装失败,出现 'subset is not a function',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66995902/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com