npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
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! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules'
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的错误提示已经指出了原因:Error: EACCES: permission denied (权限不够)
并给出了建议
Please try running this command again as root/Administrator.(使用管理员权限
使用加上sudo的npm命令(sudo: 申请root 权限)
sudo npm install -g typescript
下面是我成功的
macdeMac-mini:ts mac$ sudo npm install -g typescript
Password:
/usr/local/bin/tsc -> /usr/local/lib/node_modules/typescript/bin/tsc
/usr/local/bin/tsserver -> /usr/local/lib/node_modules/typescript/bin/tsserver
+ typescript@4.2.4
added 1 package from 1 contributor in 31.834s
macdeMac-mini:ts mac$ tsc -v
Version 4.2.4
macdeMac-mini:ts mac$ tsc index.tc
开发环境使用的是苹果的报错是npm ERR! code EACCESnpm ERR! syscall accessnpm ERR! path /usr/local/lib/node_modulesnpm ERR! errno -13npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'npm ERR! [Error: EACCES: permission denied, access '