關閉終端不記得我對 nvm/npm 的 .profile 更改 (Closing the terminal doesnt remember my .profile changes for nvm/npm)


問題描述

關閉終端不記得我對 nvm/npm 的 .profile 更改 (Closing the terminal doesnt remember my .profile changes for nvm/npm)

我使用此說明安裝了 nvm/npm

https://www.digitalocean.com/community/tutorials/how‑to‑install‑node‑js‑on‑an‑ubuntu‑14‑04‑server (如何使用 NVM 安裝),但是每次我關閉終端時,它似乎都忘記了所有設置,我必須執行以下命令:source ~/.profile 然後選擇 npm 版本以使其再次運行。如何保持我的設置永久不變,或者至少在我的登錄會話期間保持不變?謝謝!(linuxmint 17)


參考解法

方法 1:

Sourcing ~/.profile

~/.profile is typically invoked from a login shell. See http://www.gnu.org/software/bash/manual/bashref.html#Bash‑Startup‑Files

Invoked as an interactive login shell, or with ‑‑login

When Bash is invoked as an interactive login shell, or as a non‑interactive shell with the ‑‑login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The ‑‑noprofile option may be used when the shell is started to inhibit this behavior.

Opening a terminal does not typically invoke a login shell. Have you tried rebooting/relogging? Additionally if either ~/.bash_profile or ~/.bash_login exist, then bash won't source ~/.profile. There are two common ways to fix this:

Option 1

Move commands from the ~/.profile file to ~/.bash_profile

Option 2

Source ~/.profile from ~/.bash_profile:

[[ ‑f ~/.profile ]] && . ~/.profile

Default Node version

You can configure a default node version by aliasing it to default

To set a default Node version to be used in any new shell, use the alias 'default':

nvm alias default node

See https://github.com/creationix/nvm

(by Jay12Jonathan Rouleau)

參考文件

  1. Closing the terminal doesnt remember my .profile changes for nvm/npm (CC BY‑SA 2.5/3.0/4.0)

#linux-mint #npm #node.js






相關問題

C/C++語言中的Conky (Conky in C/C++ language)

關閉終端不記得我對 nvm/npm 的 .profile 更改 (Closing the terminal doesnt remember my .profile changes for nvm/npm)

在 Linux Mint 中升級 Python 版本 (Upgrade Python version in Linux Mint)

試圖消除 python3 Gtk3 錯誤信息 (Trying to eliminate python3 Gtk3 error message)

在我的 Linux Mint 上安裝 NetBeans 後出現問題,它無法執行任何操作 (i have problem after installing NetBeans on my Linux Mint it can't do anything)

Linux Mint 19.1,白色背景上的白色文本 (Linux Mint 19.1, white text on white background)

PhpStorm 找不到 Linux Mint 系統變量 (PhpStorm doesn't find Linux Mint system variables)

在 Linux Mint 上安裝 Android Studio 的問題 (Problems with Installing Android Studio on Linux Mint)

如何解決 Linux 中的“npm ERR!code ELIFECYCLE”錯誤? (How to solve "npm ERR! code ELIFECYCLE" error in Linux?)

在 Linux Mint 20.1 / Ubuntu 20.04 上安裝/卸載 Docker 後網絡連接斷開 (Broken network connection after Docker install/uninstall on Linux Mint 20.1 / Ubuntu 20.04)

如何使用 Python 和 Selenium Webdriver 在 Chrome 中加載默認配置文件? (How to load default profile in Chrome using Python and the Selenium Webdriver?)

如何使用終端重命名 linux 中的目錄? (How can I rename a directory in linux with terminal?)







留言討論