问题
I'm trying to set up an environment variable so that when I'm working on a meteor application, and I want to link a local, private package to my project, meteor will look in a packages directory that I created on my local environment.
The first thing I did was to create a packages directory and add a basic test package to it
/Users/scotty/Documents/web_apps/meteor_apps/packages/my-package
Then I opened up the terminal and typed:
nano ~/.bashrc
Once inside my bashrc file, I added the following export line:
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
export PACKAGE_DIRS="/Users/scotty/Documents/web_apps/meteor_apps/packages"
Note: The top PATH line was already there.
I then cd into a test meteor project called "test_packages" and tried to install my test package: "my-package" using the following command:
meteor add my-package
and got an error: no such package
回答1:
In my particular case and according to this post, when starting up the terminal, by default "login shell" is started, and bash does not use .bashrc for login shells.
My solution was to do the following:
open the bashrc file in an editor from the terminal (I used nano):
nano ~/.bashrcadd the environment variable to the file:
export PACKAGE_DIRS="/Users/path/to/your/packages"for me this looked like:
export PACKAGE_DIRS="/Users/scotty/Documents/web_apps/meteor_apps/packages"
if using nano, hit ctrl + x and then hit enter so save and exit
open up ~/.bash_profile:
nano ~/.bash_profileadd the following:
[[ -s ~/.bashrc ]] && source ~/.bashrcNote: this will load the ~/.bashrc file

hit ctrl + x and then enter
quite the terminal
reopen the terminal and type the command:
source ~/.bashrc
From there, you should be able to cd into your meteor application and run meteor add local-package-name. Meteor will look in your local packages directory and add the package if all went well.
来源:https://stackoverflow.com/questions/18290516/how-do-i-link-the-environment-variable-package-dirs-to-my-local-private-package

