npm install -g 打字稿失败
npm install -g typescript failing
当我 运行 npm install -g typescript
显示以下消息时:
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/typescript
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/typescript'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/typescript'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/typescript'
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/alexz/.npm/_logs/2021-12-26T10_45_08_412Z-debug.log
我尝试检查我是否已成功安装 TypeScript,如果我 运行 npm ls typescript
它显示:
alexz@ /Users/alexz
└── typescript@4.5.4
我很困惑是否安装了 TypeScript,因为如果我安装了 tsc -v
,它会告诉我 tsc
命令未找到。我该如何解决上述问题?谢谢!
这是一个权限问题。使用 sudo
命令,它会询问您的计算机密码。
sudo npm install -g typescript
当我 运行 npm install -g typescript
显示以下消息时:
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/typescript
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/typescript'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/typescript'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/typescript'
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/alexz/.npm/_logs/2021-12-26T10_45_08_412Z-debug.log
我尝试检查我是否已成功安装 TypeScript,如果我 运行 npm ls typescript
它显示:
alexz@ /Users/alexz
└── typescript@4.5.4
我很困惑是否安装了 TypeScript,因为如果我安装了 tsc -v
,它会告诉我 tsc
命令未找到。我该如何解决上述问题?谢谢!
这是一个权限问题。使用 sudo
命令,它会询问您的计算机密码。
sudo npm install -g typescript