How do I link the environment variable PACKAGE_DIRS to my local, private packages?

不打扰是莪最后的温柔 提交于 2019-12-11 03:41:30

问题


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:

  1. open the bashrc file in an editor from the terminal (I used nano): nano ~/.bashrc

  2. add 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"

  3. if using nano, hit ctrl + x and then hit enter so save and exit

  4. open up ~/.bash_profile: nano ~/.bash_profile

  5. add the following: [[ -s ~/.bashrc ]] && source ~/.bashrc

    Note: this will load the ~/.bashrc file

  6. hit ctrl + x and then enter

  7. quite the terminal

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!