由于 macOS Big Sur 升级,无法再安装 npm 包

Can't install npm packages anymore due to macOS Big Sur upgrade

升级到 macOS Big Sur 后,我无法 npm install 使用比 7 更早的 npm(所以 npm v7 没问题)。 任何时候我在清理项目文件夹(没有 node_modules 文件夹和包 - lock.json 文件)时收到错误消息 超出最大调用堆栈大小

我必须使用

ProductName:    macOS
ProductVersion: 11.0.1
BuildVersion:   20B50
Darwin: 20.1.0
nodejs v14.15.1
npm version 6.14.8

我试过了:

npm cache clean --force

npm rebuild

通过 Homebrew、nvm 手动安装 Node,并将 npm 降级到各种较低版本。

重新安装 Homebrew 以获得升级到 Big Sur 之前使用的全新背景。

重新安装 xcode 命令行工具。

运行 节点并将项目映射到 docker 容器 ubuntu:focal.

输出 return 的最后几行由 npm install --loglevel verbose:

npm http fetch GET 200 https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz 23ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz 15ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz 14ms (from cache)
npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 51352ms
npm timing stage:loadIdealTree Completed in 51653ms
npm timing stage:generateActionsToTake Completed in 225ms
npm verb correctMkdir /Users/dominikjelinek/.npm/_locks correctMkdir not in flight; initializing
npm verb lock using /Users/dominikjelinek/.npm/_locks/staging-a03ae73070af7d1f.lock for /Users/dominikjelinek/home/ccb-survey/survey/components/node_modules/.staging
npm timing audit submit Completed in 931ms
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/audits/quick 931ms
npm timing audit body Completed in 3ms
npm timing action:extract Completed in 7997ms
npm timing action:finalize Completed in 91317ms
npm verb unlock done using /Users/dominikjelinek/.npm/_locks/staging-a03ae73070af7d1f.lock for /Users/dominikjelinek/home/ccb-survey/survey/components/node_modules/.staging
npm timing stage:rollbackFailedOptional Completed in 2ms
npm timing stage:runTopLevelLifecycles Completed in 156352ms
npm WARN react-plotly.js@2.5.1 requires a peer of plotly.js@>1.34.0 but none is installed. You must install peer dependencies yourself.

npm verb stack RangeError: Maximum call stack size exceeded
npm verb stack     at RegExp.test (<anonymous>)
npm verb stack     at isDepOptional (/Users/dominikjelinek/.nvm/versions/node/v14.15.1/lib/node_modules/npm/lib/install/deps.js:432:45)
npm verb stack     at failedDependency (/Users/dominikjelinek/.nvm/versions/node/v14.15.1/lib/node_modules/npm/lib/install/deps.js:441:9)
npm verb stack     at failedDependency (/Users/dominikjelinek/.nvm/versions/node/v14.15.1/lib/node_modules/npm/lib/install/deps.js:457:9)
npm verb stack     at failedDependency (/Users/dominikjelinek/.nvm/versions/node/v14.15.1/lib/node_modules/npm/lib/install/deps.js:457:9)
npm verb stack     at failedDependency (/Users/dominikjelinek/.nvm/versions/node/v14.15.1/lib/node_modules/npm/lib/install/deps.js:457:9)
npm verb stack     at failedDependency (/Users/dominikjelinek/.nvm/versions/node/v14.15.1/lib/node_modules/npm/lib/install/deps.js:457:9)
npm verb stack     at failedDependency (/Users/dominikjelinek/.nvm/versions/node/v14.15.1/lib/node_modules/npm/lib/install/deps.js:457:9)
npm verb stack     at failedDependency (/Users/dominikjelinek/.nvm/versions/node/v14.15.1/lib/node_modules/npm/lib/install/deps.js:457:9)
npm verb stack     at failedDependency (/Users/dominikjelinek/.nvm/versions/node/v14.15.1/lib/node_modules/npm/lib/install/deps.js:457:9)
npm verb stack     at failedDependency (/Users/dominikjelinek/.nvm/versions/node/v14.15.1/lib/node_modules/npm/lib/install/deps.js:457:9)
npm verb stack     at failedDependency (/Users/dominikjelinek/.nvm/versions/node/v14.15.1/lib/node_modules/npm/lib/install/deps.js:457:9)
npm verb stack     at failedDependency (/Users/dominikjelinek/.nvm/versions/node/v14.15.1/lib/node_modules/npm/lib/install/deps.js:457:9)
npm verb stack     at failedDependency (/Users/dominikjelinek/.nvm/versions/node/v14.15.1/lib/node_modules/npm/lib/install/deps.js:457:9)
npm verb stack     at failedDependency (/Users/dominikjelinek/.nvm/versions/node/v14.15.1/lib/node_modules/npm/lib/install/deps.js:457:9)
npm verb stack     at failedDependency (/Users/dominikjelinek/.nvm/versions/node/v14.15.1/lib/node_modules/npm/lib/install/deps.js:457:9)
npm verb cwd /Users/dominikjelinek/home/ccb-survey/survey/components
npm verb Darwin 20.1.0
npm verb argv "/Users/dominikjelinek/.nvm/versions/node/v14.15.1/bin/node" "/Users/dominikjelinek/.nvm/versions/node/v14.15.1/bin/npm" "install" "--loglevel" "verbose"
npm verb node v14.15.1
npm verb npm  v6.14.8
npm ERR! Maximum call stack size exceeded

更新 1

Apple 发布了新的系统升级,但没有任何帮助。 产品版本:11.1

我不认为这是权限问题,因为我将所有 chmod -R 777 project 的项目设置为 777。

据我所知,我的朋友 运行 npm v6 on Big Sur 很好。

在 docker 容器中,我将项目从映射文件夹复制到 docker 容器中的某个其他文件夹,并且 npm install 按预期工作。

VirtualBox 中的 Windows 10 运行 也发生了同样的情况,其中 npm 不在共享文件夹上工作,但在将项目复制到 VirtualBox 中的某个内部文件夹后工作 Windows mac海因.

npm cli issue tracking 中提出了一个问题。

docker issue tracking 中提出了一个问题。

更新 2

我试图在我的 mac machine 上创建新用户以部分刷新,我按照 here 和 运行 nvm install v14.15.4 中的描述安装了 nvm使用 npm v6.14.10.

还是一样的问题。

遇到了同样的问题。通过增加文件的 ulimit.

解决了这个问题

要检查您现在有什么,请执行以下操作:

ulimit -a

应该显示如下内容:

-t: cpu time (seconds)              unlimited
-f: file size (blocks)              12288
-d: data seg size (kbytes)          unlimited
-s: stack size (kbytes)             8192
-c: core file size (blocks)         0
-v: address space (kbytes)          unlimited
-l: locked-in-memory size (kbytes)  unlimited
-u: processes                       2784
-n: file descriptors                12288

然后,要增加文件大小限制,运行以下内容:

ulimit -f [WHATEVER SIZE LIMIT YOU WANT]

对于我自己,我决定将其设置为 unlimited 以确保这不会再次成为问题,因此:

ulimit -f unlimited

就我而言,谢谢@Flowkap,所有问题:

  1. 提到npm install
  2. 双机休眠24小时以上重启
  3. 在构建过程中使用 SentryWebpackPlugin 时出错
  4. 我也提出的问题

全部通过删除趋势科技安全解决