<h3 dir="auto">Is there an existing issue for this?</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the existing issues</li>
</ul>
<p dir="auto">This <em>might</em> be a duplicate of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="849605075" data-permission-text="Title is private" data-url="https://github.com/npm/cli/issues/3021" data-hovercard-type="issue" data-hovercard-url="/npm/cli/issues/3021/hovercard" href="https://github.com/npm/cli/issues/3021">#3021</a>, but the repro is different, and hopefully easier to diagnose.</p>
<h3 dir="auto">Current Behavior</h3>
<p dir="auto"><code class="notranslate">npm install --prefix &lt;tmpdir&gt; &lt;package&gt;</code> fails on Mac OS</p>
<p dir="auto">where <code class="notranslate">&lt;tmpdir&gt;</code> is the result of <code class="notranslate">fs.mkdtempSync(path.join(os.tmpdir(), "repro")</code></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="npm ERR! Cannot read property 'spec' of undefined

55 verbose stack TypeError: Cannot read property 'spec' of undefined
55 verbose stack     at Arborist.[saveIdealTree] (/Users/nicholg/.npm/g/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:959:62)
55 verbose stack     at /Users/nicholg/.npm/g/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:139:39
55 verbose stack     at async Arborist.reify (/Users/nicholg/.npm/g/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:135:5)
55 verbose stack     at async Install.install (/Users/nicholg/.npm/g/lib/node_modules/npm/lib/install.js:137:5)"><pre class="notranslate"><code class="notranslate">npm ERR! Cannot read property 'spec' of undefined

55 verbose stack TypeError: Cannot read property 'spec' of undefined
55 verbose stack     at Arborist.[saveIdealTree] (/Users/nicholg/.npm/g/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:959:62)
55 verbose stack     at /Users/nicholg/.npm/g/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:139:39
55 verbose stack     at async Arborist.reify (/Users/nicholg/.npm/g/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:135:5)
55 verbose stack     at async Install.install (/Users/nicholg/.npm/g/lib/node_modules/npm/lib/install.js:137:5)
</code></pre></div>
<details>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="0 verbose cli [
0 verbose cli   '/usr/local/Cellar/node@14/14.17.0/bin/node',
0 verbose cli   '/Users/nicholg/.npm/g/bin/npm',
0 verbose cli   'install',
0 verbose cli   '--prefix',
0 verbose cli   '/var/folders/pt/zgtgnf1n5sl7_vw3n7dqvm5w0000gn/T/reproXMRg76',
0 verbose cli   'leftpad-i18n'
0 verbose cli ]
1 info using npm@7.13.0
2 info using node@v14.17.0
3 timing npm:load:whichnode Completed in 1ms
4 timing config:load:defaults Completed in 2ms
5 timing config:load:file:/Users/nicholg/.npm/g/lib/node_modules/npm/npmrc Completed in 1ms
6 timing config:load:builtin Completed in 1ms
7 timing config:load:cli Completed in 2ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:/var/folders/pt/zgtgnf1n5sl7_vw3n7dqvm5w0000gn/T/reproXMRg76/.npmrc Completed in 1ms
10 timing config:load:project Completed in 1ms
11 timing config:load:file:/Users/nicholg/.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:/var/folders/pt/zgtgnf1n5sl7_vw3n7dqvm5w0000gn/T/reproXMRg76/etc/npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:validate Completed in 1ms
16 timing config:load:credentials Completed in 1ms
17 timing config:load:setEnvs Completed in 0ms
18 timing config:load Completed in 8ms
19 timing npm:load:configload Completed in 8ms
20 timing npm:load:setTitle Completed in 3ms
21 timing npm:load:setupLog Completed in 1ms
22 timing npm:load:cleanupLog Completed in 2ms
23 timing npm:load:configScope Completed in 0ms
24 timing npm:load:projectScope Completed in 1ms
25 timing npm:load Completed in 16ms
26 timing config:load:flatten Completed in 2ms
27 timing arborist:ctor Completed in 1ms
28 timing arborist:ctor Completed in 0ms
29 timing idealTree:init Completed in 18ms
30 timing idealTree:userRequests Completed in 2ms
31 silly idealTree buildDeps
32 silly fetch manifest leftpad-i18n@*
33 http fetch GET 304 https://registry.npmjs.org/leftpad-i18n 171ms (from cache)
34 silly placeDep ROOT leftpad-i18n@1.1.0 OK for:  want: *
35 timing idealTree:#root Completed in 178ms
36 timing idealTree:node_modules/leftpad-i18n Completed in 0ms
37 timing idealTree:buildDeps Completed in 180ms
38 timing idealTree:fixDepFlags Completed in 0ms
39 timing idealTree Completed in 201ms
40 timing reify:loadTrees Completed in 202ms
41 timing reify:diffTrees Completed in 0ms
42 silly reify moves {}
43 timing reify:retireShallow Completed in 0ms
44 timing reify:createSparse Completed in 0ms
45 timing reify:loadBundles Completed in 0ms
46 silly audit bulk request { 'leftpad-i18n': [ '1.1.0' ] }
47 timing reify:unpack Completed in 0ms
48 timing reify:unretire Completed in 1ms
49 timing build:queue Completed in 0ms
50 timing build:deps Completed in 0ms
51 timing build Completed in 0ms
52 timing reify:build Completed in 0ms
53 timing reify:trash Completed in 0ms
54 timing command:install Completed in 219ms
55 verbose stack TypeError: Cannot read property 'spec' of undefined
55 verbose stack     at Arborist.[saveIdealTree] (/Users/nicholg/.npm/g/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:959:62)
55 verbose stack     at /Users/nicholg/.npm/g/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:139:39
55 verbose stack     at async Arborist.reify (/Users/nicholg/.npm/g/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:135:5)
55 verbose stack     at async Install.install (/Users/nicholg/.npm/g/lib/node_modules/npm/lib/install.js:137:5)
56 verbose cwd /Users/nicholg/q
57 verbose Darwin 20.4.0
58 verbose argv &quot;/usr/local/Cellar/node@14/14.17.0/bin/node&quot; &quot;/Users/nicholg/.npm/g/bin/npm&quot; &quot;install&quot; &quot;--prefix&quot; &quot;/var/folders/pt/zgtgnf1n5sl7_vw3n7dqvm5w0000gn/T/reproXMRg76&quot; &quot;leftpad-i18n&quot;
59 verbose node v14.17.0
60 verbose npm  v7.13.0
61 error Cannot read property 'spec' of undefined
62 verbose exit 1"><pre class="notranslate"><code class="notranslate">0 verbose cli [
0 verbose cli   '/usr/local/Cellar/node@14/14.17.0/bin/node',
0 verbose cli   '/Users/nicholg/.npm/g/bin/npm',
0 verbose cli   'install',
0 verbose cli   '--prefix',
0 verbose cli   '/var/folders/pt/zgtgnf1n5sl7_vw3n7dqvm5w0000gn/T/reproXMRg76',
0 verbose cli   'leftpad-i18n'
0 verbose cli ]
1 info using npm@7.13.0
2 info using node@v14.17.0
3 timing npm:load:whichnode Completed in 1ms
4 timing config:load:defaults Completed in 2ms
5 timing config:load:file:/Users/nicholg/.npm/g/lib/node_modules/npm/npmrc Completed in 1ms
6 timing config:load:builtin Completed in 1ms
7 timing config:load:cli Completed in 2ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:/var/folders/pt/zgtgnf1n5sl7_vw3n7dqvm5w0000gn/T/reproXMRg76/.npmrc Completed in 1ms
10 timing config:load:project Completed in 1ms
11 timing config:load:file:/Users/nicholg/.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:/var/folders/pt/zgtgnf1n5sl7_vw3n7dqvm5w0000gn/T/reproXMRg76/etc/npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:validate Completed in 1ms
16 timing config:load:credentials Completed in 1ms
17 timing config:load:setEnvs Completed in 0ms
18 timing config:load Completed in 8ms
19 timing npm:load:configload Completed in 8ms
20 timing npm:load:setTitle Completed in 3ms
21 timing npm:load:setupLog Completed in 1ms
22 timing npm:load:cleanupLog Completed in 2ms
23 timing npm:load:configScope Completed in 0ms
24 timing npm:load:projectScope Completed in 1ms
25 timing npm:load Completed in 16ms
26 timing config:load:flatten Completed in 2ms
27 timing arborist:ctor Completed in 1ms
28 timing arborist:ctor Completed in 0ms
29 timing idealTree:init Completed in 18ms
30 timing idealTree:userRequests Completed in 2ms
31 silly idealTree buildDeps
32 silly fetch manifest leftpad-i18n@*
33 http fetch GET 304 https://registry.npmjs.org/leftpad-i18n 171ms (from cache)
34 silly placeDep ROOT leftpad-i18n@1.1.0 OK for:  want: *
35 timing idealTree:#root Completed in 178ms
36 timing idealTree:node_modules/leftpad-i18n Completed in 0ms
37 timing idealTree:buildDeps Completed in 180ms
38 timing idealTree:fixDepFlags Completed in 0ms
39 timing idealTree Completed in 201ms
40 timing reify:loadTrees Completed in 202ms
41 timing reify:diffTrees Completed in 0ms
42 silly reify moves {}
43 timing reify:retireShallow Completed in 0ms
44 timing reify:createSparse Completed in 0ms
45 timing reify:loadBundles Completed in 0ms
46 silly audit bulk request { 'leftpad-i18n': [ '1.1.0' ] }
47 timing reify:unpack Completed in 0ms
48 timing reify:unretire Completed in 1ms
49 timing build:queue Completed in 0ms
50 timing build:deps Completed in 0ms
51 timing build Completed in 0ms
52 timing reify:build Completed in 0ms
53 timing reify:trash Completed in 0ms
54 timing command:install Completed in 219ms
55 verbose stack TypeError: Cannot read property 'spec' of undefined
55 verbose stack     at Arborist.[saveIdealTree] (/Users/nicholg/.npm/g/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:959:62)
55 verbose stack     at /Users/nicholg/.npm/g/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:139:39
55 verbose stack     at async Arborist.reify (/Users/nicholg/.npm/g/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:135:5)
55 verbose stack     at async Install.install (/Users/nicholg/.npm/g/lib/node_modules/npm/lib/install.js:137:5)
56 verbose cwd /Users/nicholg/q
57 verbose Darwin 20.4.0
58 verbose argv "/usr/local/Cellar/node@14/14.17.0/bin/node" "/Users/nicholg/.npm/g/bin/npm" "install" "--prefix" "/var/folders/pt/zgtgnf1n5sl7_vw3n7dqvm5w0000gn/T/reproXMRg76" "leftpad-i18n"
59 verbose node v14.17.0
60 verbose npm  v7.13.0
61 error Cannot read property 'spec' of undefined
62 verbose exit 1
</code></pre></div>
</details>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">Installation succeeds as it does if I downgrade to npm 6.x.</p>
<h3 dir="auto">Steps To Reproduce</h3>
<p dir="auto">Using environment described below, create a repro.js file with the following:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const { spawnSync } = require(&quot;child_process&quot;);
const { mkdtempSync } = require(&quot;fs&quot;);
const { tmpdir } = require(&quot;os&quot;);
const { join } = require(&quot;path&quot;);

const dir = mkdtempSync(join(tmpdir(), &quot;repro&quot;));
console.log(`&gt; npm install --prefix ${dir} &quot;leftpad-i18n&quot;\n`);
spawnSync(&quot;npm&quot;, [&quot;install&quot;, &quot;--prefix&quot;, dir, &quot;leftpad-i18n&quot; ], {
  stdio: &quot;inherit&quot;,
});"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-kos">{</span> spawnSync <span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">"child_process"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-kos">{</span> mkdtempSync <span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">"fs"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-kos">{</span> tmpdir <span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">"os"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-kos">{</span> join <span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">"path"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-k">const</span> <span class="pl-s1">dir</span> <span class="pl-c1">=</span> <span class="pl-en">mkdtempSync</span><span class="pl-kos">(</span><span class="pl-en">join</span><span class="pl-kos">(</span><span class="pl-en">tmpdir</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-s">"repro"</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">`&gt; npm install --prefix <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">dir</span><span class="pl-kos">}</span></span> "leftpad-i18n"\n`</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-en">spawnSync</span><span class="pl-kos">(</span><span class="pl-s">"npm"</span><span class="pl-kos">,</span> <span class="pl-kos">[</span><span class="pl-s">"install"</span><span class="pl-kos">,</span> <span class="pl-s">"--prefix"</span><span class="pl-kos">,</span> <span class="pl-s1">dir</span><span class="pl-kos">,</span> <span class="pl-s">"leftpad-i18n"</span> <span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
  <span class="pl-c1">stdio</span>: <span class="pl-s">"inherit"</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Then run it:</p>
<blockquote>
<p dir="auto">node repro.js</p>
</blockquote>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>OS: mac OS Big Sur 11.3.1</li>
<li>Node: 14.17.0</li>
<li>npm: 7.13.0</li>
</ul>
<p dir="auto">Hello</p>
<p dir="auto">I tried to install ffmpeg by :</p>
<blockquote>
<p dir="auto">sudo npm install --save @ffmpeg-installer/ffmpeg<br>
return npm ERR! "cb() never called"</p>
</blockquote>
<blockquote>
<p dir="auto">npm -v<br>
6.13.7<br>
node -v<br>
v13.7.0</p>
</blockquote>
<p dir="auto">OS : Linux Mint 19.3 Tricia base ubuntu bionic</p>
<p dir="auto">I can install express without a problem.<br>
Ask : Is it a chmod problem? A graphic card problem or an npm problem?</p>