Catalina 不会让我安装 gulp 或其他使用 npm 的应用程序

Catalina wont let me install gulp or other apps using npm

我全新安装了 Mac OS Catalina,它不允许我安装 npm 应用程序。我尝试了 sudo 和非 sudo。

npm install --global browser-sync

但是出现了这个错误,

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/browser-sync
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules/browser-sync
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/browser-sync'
npm ERR!  [Error: EACCES: permission denied, access '/usr/local/lib/node_modules/browser-sync'] {
npm ERR!   stack: "Error: EACCES: permission denied, access '/usr/local/lib/node_modules/browser-sync'",
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules/browser-sync'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/nicholasdixon/.npm/_logs/2019-12-14T07_09_23_421Z-debug.log

这是重新安装 OS 的 UNIX 问题。

您可以通过在终端中输入以下内容来修复它:

sudo chown -R $USER /usr/local/lib/node_modules

这对我有用,希望对你也有用。