What you can do is to e.g. Resolve the command you want to run (node or npm) in your own user's shell using process substitution with which: sudo '$(which npm)' install -g angular-cli sudo '$(which node)' app.js This first runs which npm or which node as your user, which returns the absolute path of the executables belonging to the specified. Once the source code is done downloading, use the CD command to move the terminal session into the “app-outlet” directory. From here, you can install the project’s dependency files with the npm command. Finally, compile the source code for App Outlet. Install EasyRTC dependencies from NPM. In the console, enter the serverexample folder. Cd serverexample. Install EasyRTC Sample Server dependencies from NPM. Npm install; Running EasyRTC Server From Console. Running the server from the console may be the best approach for development. Since Randall's script does not use sudo for any but the apt-get command, there are two possibilities: the script itself was run via the root user or via sudo, in which case the sudo apt-get is not needed, or the script was run as a normal user, in this case the commands may install a local (as opposed to system-wide) version depending on local. It's possible (and advisable) to npm install -g node modules without sudo. Check the permission of your /usr/local/share/npm/bin folder. I had installed node and npm through brew (without sudo) and that particular folder ended up being owned by root. This fixed it for once and for all: $ sudo chown $(whoami) /usr/local/share/npm/bin.
In this tutorial we will learn to install TypeScript on Mac using NPM a NodeJS package manager.
Step 1: Install Homebrew
Homebrew is a package manager for Mac and helps to easily install and uninstall softwares on a Mac.
To install Homebrew run the following command in the terminal.
For more detail on Homebrew check their website.
Once you have homebrew installed on your system you can use it to install many packages.
Step 2: Install Node
By installing NodeJS you will also get NPM which is Node package manager. It will help you to install other packages.
To install Node on your Mac using Homebrew type the following command.
Once you have Node installed you can check its version by typing the following command in the terminal.
And, to check the version of NPM type the following command in the terminal.
Sudo Sh Cd App_directory Npm Install In Mac Download
Click here to read the tutorial on How to install NodeJS on Mac.
So, now we have Node and NPM installed on our system. Time to install TypeScript using NPM.
Step 3: Install TypeScript
We will install TypeScript globally on our Mac so that we can access it from any directory. For this we will use the following command.
You may have to use sudo
if you don't have permissions.
Output
Once you have TypeScript installed use the following command to check the version.
Output
Sudo Sh Cd App_directory Npm Install In Mac Os
Using TypeScript to convert .TS file into .JS file
Lets say, we have a project folder example and we have an app.ts TypeScript file which we want to convert into JavaScript file.
The content of app.ts file is given below.
To convert app.ts file into app.js file we use the following command in the terminal.
Output
Uninstall TypeScript
To uninstall TypeScript globally we use the following command.
You may have to use sudo
if you don't have the permissions.
Sudo Sh Cd App_directory Npm Install In Mac High Sierra
Output
And that's all for this tutorial. Have fun coding.
Sudo Sh Cd App_directory Npm Install In Macbook Pro
# 安装oh-my-zsh |
sh -c '$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)' |
# 安装Homebrew |
/bin/zsh -c '$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)' |
# 安装常用服务 |
brew install tree wget zsh-syntax-highlighting node zsh-autosuggestions |
echo'export PATH='/usr/local/opt/openssl@1.1/bin:$PATH''>>~/.zshrc |
echo'export LDFLAGS='-L/usr/local/opt/openssl@1.1/lib''>>~/.zshrc |
echo'export CPPFLAGS='-I/usr/local/opt/openssl@1.1/include''>>~/.zshrc |
# 创建常用目录 |
mkdir ~/Documents/sdk |
mkdir ~/Documents/Workspace |
mkdir ~/Documents/Playgrounds |
# 安装常用app |
brew cask install clash-for-windows font-fira-code font-oppo-sans |
brew cask install android-studio microsoft-edge visual-studio-code |
brew cask install github iterm2 intellij-idea iina rectangle utools keka |
brew cask install wechatwork notion spark |
# 安装node常用环境 |
npm install yarn -g |
yarn global add vite @vue/cli eslint nuxt prettier yo generator-code |
# 安装flutter |
## 需提前安装并初始化Android stuido和XCode |
git clone -b master https://github.com/flutter/flutter.git ~/Documents/sdk/flutter |
echo'nnn'| tee -a ~/.bash_profile ~/.zshrc |
echo'export FLUTTER_ROOT=~/Documents/sdk/fluttern'| tee -a ~/.bash_profile ~/.zshrc |
echo'PATH=$FLUTTER_ROOT/bin/cache/dart-sdk/bin:$FLUTTER_ROOT/bin:$PATHn'| tee -a ~/.bash_profile ~/.zshrc |
echo'export PUB_HOSTED_URL=https://pub.flutter-io.cnn'| tee -a ~/.bash_profile ~/.zshrc |
echo'export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cnn'| tee -a ~/.bash_profile ~/.zshrc |
flutter |
flutter precache |
flutter doctor --android-licenses |
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer |
sudo xcodebuild -runFirstLaunch |
sudo gem install cocoapods |
flutter doctor |
# 常用命令 |
echo'alias workspace='cd ~/Documents/WorkSpace/'n'| tee -a ~/.bash_profile ~/.zshrc |
echo'alias playground='cd ~/Documents/Playgrounds/'n'| tee -a ~/.bash_profile ~/.zshrc |
echo'alias brewcheck='socks brew update && brew upgrade'n'| tee -a ~/.bash_profile ~/.zshrc |
echo'alias socks='ALL_PROXY=socks5://127.0.0.1:7890'n'| tee -a ~/.bash_profile ~/.zshrc |
#复制 vim 配置模版 |
cp /usr/share/vim/vimrc ~/.vimrc |
#开启语法高亮 |
echo'syntax on'>>~/.vimrc |
#开启行号显示 |
echo'set nu!'>>~/.vimrc |
#将 Powerline 字体文件下载到「下载」文件夹中 |
cd~/Downloads && git clone https://github.com/powerline/fonts.git |
#安装所有 Powerline 字体 |
cd fonts && ./install.sh |
#删除下载的字体文件 |
cd&& rm -rf ~/Downloads/fonts |
# 配置oh-my-zsh |
_omz::theme use agnoster |
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting |
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions |
#声明终端类型 |
echo'export TERM=xterm-256color'>>~/.zshrc |
#设置建议命令的文字颜色 |
echo'ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=10''>>~/.zshrc |
# 更新环境配置 |
source~/.zshrc |