Will Squire
Will Squire

Reputation: 6595

How to install Dart to be used in the terminal? (command line)

How do you install Dart so the language can be used within the terminal? (For UNIX based systems, such as a Mac)

Upvotes: 4

Views: 3419

Answers (2)

Andrew
Andrew

Reputation: 38029

1) Install Dart in your environment (if have not yet)

https://www.dartlang.org/tools/sdk#install

2) Add PATH variable for dart/bin

Example for Ubuntu

# add path example
echo 'export PATH="$PATH:/usr/lib/dart/bin"' >> ~/.bashrc
source .bashrc

or it can be .bash_profile instead of .bashrc

3) And now just run your .dart file with the main() method in the terminal and see an output

$ dart path_to_your_file/your_file_with_main.dart

Upvotes: 1

Will Squire
Will Squire

Reputation: 6595

After installing Dart (currently located at https://www.dartlang.org/), you will need to do some additional work to use dart commands in the terminal (command line), as it needs to be added to the Bash profile PATHs (on a UNIX based system). To do this, run the following handy command to open the .bash_profile file in it’s default location and with the system’s default text editor touch ~/.bash_profile; open ~/.bash_profile.

Next find the directory that Dart was downloaded to and put the path for dart-sdk/bin inside the .bash_profile as apart of the PATH variable. I.e. a line of code should be added to this file that looks something like this (if you’ve put the dart install in the applications folder on a Mac): export PATH=$PATH:/Applications/Dart/dart-sdk/bin.

To get Bash to start using this new profile immediately without restart, enter source ~/.bash_profile in the terminal (command line), then to double check the PATHs have updated, by enter in the command echo $PATH.

Upvotes: 5

Related Questions