質問するログイン新規登録

Q&A

解決済

1回答

650閲覧

fish shell でnode バージョンを永久的に最新版にする方法が知りたい

samidare_chan

総合スコア18

fish

fish(friendly interactive shell)は、Unix系OSのシェルの一つです。無設定で多くの機能を利用することが可能。カラフルな表示で見やすく、TAB補完にも優れています。

terminal

Terminalは、Apple社のmacOSに標準で付属しているUNIX端末エミュレータ。UNIXコマンドによってMacの操作および設定を行うことができます。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

Linux

Linuxは、Unixをベースにして開発されたオペレーティングシステムです。日本では「リナックス」と呼ばれています。 主にWebサーバやDNSサーバ、イントラネットなどのサーバ用OSとして利用されています。 上位500のスーパーコンピュータの90%以上はLinuxを使用しています。 携帯端末用のプラットフォームAndroidは、Linuxカーネル上に構築されています。

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

0グッド

1クリップ

投稿2023/12/23 05:41

0

1

質問内容

提示のコンソールログですがnvmを用いてnodeを最新版に切り替えたいのでのですが参考サイト通りにやってもエラーでてしまいます。
これは何が原因なのでしょうか?

知りたいこと

永久的にバージョンを切り替える正規のやり方が知りたい。
コマンドがエラーになる原因が知りたい

行ったこと

1,参考サイトAのサイトを参考に同じように行い、Gihubサイトの必要な物をすべてインストールしましたが下記のエラーコンソールが表示されます。
2,config.fishファイルにnvm use v21.5.0というコードを書いて起動時に一時的に設定する設定を書いて事実上の永久設定を行う事で
設定しているのですが、本来のやり方ではないと思うんで質問しました。
3,nvm -h を見ると exmple部にaliasというコマンドがないのでバージョンの関係で削除されたと思われます。

参考サイト

A: https://saki-htr.hatenablog.com/entry/2021/08/12/180228#Node%E3%81%A8Nodejs%E3%81%AE%E9%81%95%E3%81%84%E3%81%AF

環境

OS: ubnutu 20.4
shell: fitsh
フレームワーク:on my fish

エラーコンソール
$ nvm alias default nvm: Unknown command or option: "alias" (see nvm -h for usage)
一時的に設定
$ nvm use v21.5.0 Now using Node v21.5.0 (npm 10.2.4) ~/.local/share/nvm/v21.5.0/bin/node $~/.c/fish  node -v v21.5.0
nvm -h
nvm -h Usage: nvm install <version> Download and activate the specified Node version nvm install Install the version specified in the nearest .nvmrc file nvm use <version> Activate the specified Node version in the current shell nvm use Activate the version specified in the nearest .nvmrc file nvm list List installed Node versions nvm list-remote List available Node versions to install nvm list-remote <regex> List Node versions matching a given regex pattern nvm current Print the currently-active Node version nvm uninstall <version> Uninstall the specified Node version Options: -s, --silent Suppress standard output -v, --version Print the version of nvm -h, --help Print this help message Variables: nvm_arch Override architecture, e.g. x64-musl nvm_mirror Use a mirror for downloading Node binaries nvm_default_version Set the default version for new shells nvm_default_packages Install a list of packages every time a Node version is installed Examples: nvm install latest Install the latest version of Node nvm use 14.15.1 Use Node version 14.15.1 nvm use system Activate the system's Node version

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

guest

回答1

0

ベストアンサー

まず、fish は POSIX-compliant ではありません。NVM の公式サイト を見ると

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

と書いてあり fish 上で動作することが期待できません。更に、

Note: nvm does not support Fish either (see #303). Alternatives exist, which are neither supported nor developed by us:

と書いてあるので「正規のやり方」はそもそも存在しないということです。

nvm を使うのを諦めて、fish 用に作られた https://github.com/jorgebucaran/nvm.fish などを使うことをおすすめします。(私は試していません、が、良さそうに見えます。)

投稿2024/05/29 13:42

編集2024/05/29 14:40
Paalon

総合スコア266

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.29%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問