Can't install TypeScript on MacOS - Terminal Error

Multi tool use
Multi tool use


Can't install TypeScript on MacOS - Terminal Error



I have Visual Studio Code on my Mac and want to install TypeScript for Angular. I already previously installed Node.js or Git I think. This command from the TypeScript website should install TypeScript if it's run in the Mac Terminal, but it doesn't:


npm install -g typescript



If I paste it in the Terminal and press enter, this Error-code appears in the Terminal: (What is the problem? I really don't get it and have no clue about the terminal, I'm not a computer pro. Would be a big help if you have tips in easy words for beginners. Thanks!!)


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).





you need to use sudo
– Joe Warner
Jun 30 at 20:19




1 Answer
1



npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules



means you need permissions to download to that location, the reason it requires root privileges is likely because you installed nodejs/npm with root privileges.



sudo npm install -g typescript


sudo npm install -g typescript



then type in your password





I have no enough reputation for upvote yet, but big thanks for your help. Seems like it worked. I think with that response from terminal it should be alright: /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@2.9.2 added 1 package from 1 contributor in 1.177s MacBook-Pro:~
– stack12321
Jun 30 at 20:41



/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@2.9.2 added 1 package from 1 contributor in 1.177s MacBook-Pro:~





refer to this answer if you want to resolve it :) stackoverflow.com/questions/33725639/…
– Joe Warner
Jun 30 at 20:42





What do you mean by that can you please tell more detailed? :-) (I'm very new to stackoverflow and coding still)
– stack12321
Jun 30 at 20:44






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

9c07TChgdKlRL32yY,IUasz 2uvnzK8ISCCt0,JzvsXrg57Qor Yec,SADfGCPO RQ Rrn,cJeAlYEv8kj XTYum,wgd
6 JRHANrvCIAXx bi,KF9E dSCGY2wkQxBfXIT8VF

Popular posts from this blog

PySpark - SparkContext: Error initializing SparkContext File does not exist

django NoReverseMatch Exception

List of Kim Possible characters