简体   繁体   English

将Express添加到NodeJS中的Path

[英]Add express to Path in NodeJS

Hi im working on NodeJS with express in Mac OS, After install: with brew: https://changelog.com/posts/install-node-js-with-homebrew-on-os-x 嗨,我在Mac OS中使用Express在NodeJS上工作,安装后:带有brew: https : //changelog.com/posts/install-node-js-with-homebrew-on-os-x

Shows me: 显示给我:

/Users/dortiz/.npm-packages/bin/express -> /Users/dortiz/.npm-packages/lib/node_modules/express-generator/bin/express-cli.js

And if I will execute: 如果我执行:

daortiz:~ dortiz$ express -bash: express: command not found daortiz:〜dortiz $ express -bash:express:找不到命令

But: 但:

/Users/dortiz/.npm-packages/bin/express /用户/dortiz/.npm-packages/bin/express

Its working, 它的工作,

Im trying to export a path with 我试图用导出路径

export PATH=$PATH:/Users/dortiz/.npm-packages/bin/ 导出PATH = $ PATH:/Users/dortiz/.npm-packages/bin/

Its success, but if I close and reopen the terminal don't works command 它成功,但是如果我关闭并重新打开终端,将无法使用命令

But doesn't works, any one know what I doing wrong? 但是不行,有人知道我做错了吗?

您需要将该行添加到将在登录时获取的文件中,例如: ~/.bash_profile

Using export sets environment variables for current shell only. 使用export只能为当前shell设置环境变量。 Once shell is terminated environment variables for that shell no longer exist. 终止外壳程序后,该外壳程序的环境变量将不再存在。 In order to set environment variables for all shell that are initiated you should put them in ~/.bash_profile as pointed by mailo. 为了为所有启动的shell设置环境变量,您应该将它们放在mailo所指的〜/ .bash_profile中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM