如何将环境变量PACKAGE_DIRS链接到本地​​私有软件包? [英] How do I link the environment variable PACKAGE_DIRS to my local, private packages?

查看:138
本文介绍了如何将环境变量PACKAGE_DIRS链接到本地​​私有软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置一个环境变量,以便在处理流星应用程序时,我想将本地私有程序包链接到我的项目,流星将在我创建的程序包目录中查找我当地的环境.

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.

我要做的第一件事是创建一个packages目录并向其中添加一个基本的测试包

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

在我的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"

注意:顶部的PATH行已经在那里.

Note: The top PATH line was already there.

然后我进入名为"test_packages"的测试流星项目,并尝试使用以下命令安装测试包:"my-package":

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

推荐答案

在我的特定情况下,并根据

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. 在终端的编辑器中打开bashrc文件(我使用过nano):nano ~/.bashrc

将环境变量添加到文件中:

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"

如果使用nano,请按ctrl + x,然后按Enter键,然后保存并退出

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

打开〜/.bash_profile:nano ~/.bash_profile

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

添加以下内容:[[ -s ~/.bashrc ]] && source ~/.bashrc

注意:这会加载〜/.bashrc文件

Note: this will load the ~/.bashrc file

按ctrl + x,然后输入

hit ctrl + x and then enter

退出终端

重新打开终端并键入命令:source ~/.bashrc

reopen the terminal and type the command: source ~/.bashrc

从那里,您应该能够进入流星应用程序并运行meteor add local-package-name.如果一切顺利,Meteor将查找您本地的软件包目录并添加该软件包.

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.

这篇关于如何将环境变量PACKAGE_DIRS链接到本地​​私有软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆