当前位置: 首页 > 知识库问答 >
问题:

无法在MacOS上安装TypeScript-终端错误

锺离韬
2023-03-14

我有Visual Studio Code在我的Mac和想安装TypeScript的角。我以前已经安装了Node.js或Git我想。来自TypeScript网站的这个命令应该安装TypeScript,如果它在Mac终端中运行,但是它没有:

npm install -g typescript

如果我将其粘贴到终端中并按enter键,终端中会出现以下错误代码:(问题出在哪里?我真的不明白,也不知道终端是什么,我不是电脑专家。如果你有简单易懂的提示,对初学者会有很大帮助。谢谢!!)

MacBook-Pro:~ Max$ npm install -g typescript
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }
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 (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/Max/.npm/_logs/2018-06-30T14_50_35_633Z-debug.log
MacBook-Pro:~ Max$ clear

    MacBook-Pro:~ Max$ npm install -g typescript
    npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
    npm ERR! path /usr/local/lib/node_modules
    npm ERR! code EACCES
    npm ERR! errno -13
    npm ERR! syscall access
    npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
    npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
    npm ERR!   stack:
    npm ERR!    'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
    npm ERR!   errno: -13,
    npm ERR!   code: 'EACCES',
    npm ERR!   syscall: 'access',
    npm ERR!   path: '/usr/local/lib/node_modules' }
    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 (though this is not recommended).

    npm ERR! A complete log of this run can be found in:
    npm ERR!     /Users/Max/.npm/_logs/2018-06-30T14_58_29_869Z-debug.log
    MacBook-Pro:~ Max$ clear

    MacBook-Pro:~ Max$ npm install -g typescript
    npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
    npm ERR! path /usr/local/lib/node_modules
    npm ERR! code EACCES
    npm ERR! errno -13
    npm ERR! syscall access
    npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
    npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
    npm ERR!   stack:
    npm ERR!    'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
    npm ERR!   errno: -13,
    npm ERR!   code: 'EACCES',
    npm ERR!   syscall: 'access',
    npm ERR!   path: '/usr/local/lib/node_modules' }
    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 (though this is not recommended).

共有1个答案

曹和正
2023-03-14

npm警告检查权限缺少对 /usr/local/lib/node_modules的写访问权限

意味着您需要下载到该位置的权限,它需要root权限的原因可能是因为您使用root权限安装了nodejs/npm。

sudo npm安装-g typescript

然后输入密码

 类似资料:
  • 当我像这样在终端上输入时: 它向我展示了这样的错误: 错误:安装cocoapods错误:错误:无法构建gem本机扩展。 /系统/库/框架/Ruby。framework/Versions/2.6/usr/bin/ruby-I/Library/ruby/Site/2.6.0-r/siteconf20201203-2632-pfzsbj。rb extconf。rb正在检查外国金融机构。h、 ..**ex

  • 在macOS上,我在终端中运行了这个命令: 它开始安装,然后抛出这个错误: 错误:命令出错,退出状态为1:/Library/framework/python . framework/Versions/3.8/bin/python 3.8-u-c ' import sys,setuptools,tokenize。sys . argv[0]= ' " ' " '/private/tmp/pip-ins

  • 逐步执行说明: https://cloud.google.com/sdk/docs/quickstart 解压存档 正在运行 收到此消息: 欢迎使用Google Cloud SDK! 就这些。 有什么办法让它工作吗?

  • 所以当我的终端显示我没有python时,我试图安装python,这很奇怪,因为我认为我有。当我试图找到它时,我找不到它,我使用如下命令: 当我试图删除python时(我正在尝试随机操作): 然后此错误将显示:操作无法完成。无法找到Java运行时。请访问http://www.java.com以获取有关安装Java的信息。 当我尝试用安装时 然后会抛出相同的Java错误。 更新:抱歉,我在macOS蒙

  • 试图让php/imagick在运行OS 10.15的mac上运行。3(Catalina)使用brew。我安装了Php(7.4.3)我安装了imagemagic(7.0.9-23),当我pecl安装imagick时,我得到: 文件夹存在且为空且具有权限 加载文件不会失败,因为该示例不会使安装失败。消息听起来好像无法读取源代码,但我不确定。有人有什么想法吗?