fish-nvm

nvm wrapper for fish-shell
授权协议 MIT License
开发语言 JavaScript
所属分类 Web应用开发、 常用JavaScript包
软件类型 开源软件
地区 不详
投 递 者 谷奕
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

fish-nvm

NVM wrapper for fish-shell.

Install

Make sure you have NVM installed first.

With Fisher

fisher install FabioAntunes/fish-nvm edc/bass

With oh-my-fish

omf install https://github.com/fabioantunes/fish-nvm
omf install https://github.com/edc/bass

With fundle

fundle plugin 'FabioAntunes/fish-nvm'
fundle plugin 'edc/bass'
fundle install

Add these lines to ~/.config/fish/config.fish

fundle plugin 'FabioAntunes/fish-nvm'
fundle plugin 'edc/bass'
fundle init

fish-nvm depends on bass

Usage

nvm install 6.11.1
nvm alias default 6.11.1

How it works

The way this plugin works is delaying sourcing NVM, until we really need it. That way we don't have those annoying 1/2 seconds of delay every time we open a new terminal window/tab.

By delaying the sourcing of NVM YOUR NODE BINARIES WON'T BE LOADED until you source NVM or run one of the following aliases. If you want to source NVM every single time you open a terminal just use bass

There are a couple of aliases already created. These will source NVM whenever you call them:

  • npm
  • yarn
  • node
  • nvm
  • npx

What this means is that if you depend on other node global packages, let's say gulp, if you try to run gulp in a new window/tab you will get something like Command unknown.One way to solve this is running nvm use default, or any of the aliases before using the command gulp. If you primarily depend on these global packages, that's far from great.

One possible way is for you to manually create your function inside ~/.config/fish/functions, so for gulp would be something like this:

function gulp -d "gulp task manager" -w gulp
  __nvm_run "gulp" $argv
end

To simplify this process there's an helper function on fish-nvm just run nvm_alias_function name, you can pass multiple packages names, separated by spaces:

nvm_alias_function gulp webpack grunt

This will create 3 functions on your functions folder ~/.config/fish/functions

Another common scenario is if you need to have the binary of the node or package available. For example, if you are a vim user, some plugins need access to the node binary.Since we only source NVM when we use one of the aliases, you will probably get an error saying that node isn't available

Again one possible way is for you to manually create an alias binary for node in the folder /usr/local/bin

touch /usr/local/bin/node

Open that file on your editor and paste the following:

#! /usr/bin/env fish

__nvm_run "node" $argv

Make that file executable:

chmod +x /usr/local/bin/node

Test it

which node

To simplify this process there's another helper function nvm_alias_command

If you run nvm_alias_command without any arguments it will create the following aliases binaries by default:

  • npm
  • node
  • npx
  • yarn

To create additional aliases, you can pass them as arguments separated by spaces

nvm_alias_command eslint prettier

The default output path is /urs/local/bin, if you get an error message due to permissions, try running with sudo permissions:

sudo fish nvm_alias_command eslint prettier

To change the default output folder, you can set a global variable:

set -g nvm_alias_output /other/path

Please read these Notes:

Sometimes it might happen NVM is already sourced, with the wrong version, or not respecting your default version. Check your ~/.profile or ~/.bashrc or ~/.bash_profile. If that's the case, remove the line that sources NVM.

Make sure you set a default node version or create a .nvmrc file on your working directory.fish-nvm will try to use the .nvmrc version specified, if the file exists, if there's no file it will try to use the default version.

If you don't use the .nvmrc file or if you don't set a default version, you will have to run nvm use node-version every time you open a new terminal and want to use node or npm

If you have a custom $NVM_DIR, please add the following line to your ~/.config/fish/config.fish, replacing the path accordingly:

set -gx NVM_DIR /path/to/nvm

Also, if you have a custom installation path but still set $NVM_DIR to default path. For example this could happen if you install NVM using brew, which would install NVM into: /usr/local/Cellar/nvm/%nvm_version%/nvm.sh

If that is the case, you need to add the following line to your ~/.config/fish/config.fish, replacing the path accordingly:

set -gx nvm_prefix /path/to/nvm

NOTE:

DO NOT use a trailing slash in NVM_DIR variable.Adding it will cause error: nvm is not compatible with the npm config "prefix" option

License

fish-nvm is MIT licensed.

  • 1.卸载已安装到全局的 node/npm 如果之前是在官网下载的 node 安装包,运行后会自动安装在全局目录,其中 node 命令在 /usr/local/bin/node ,npm 命令在全局 node_modules 目录中,具体路径为 /usr/local/lib/node_modules/npm 安装 nvm 之后最好先删除下已安装的 node 和全局 node 模块:   #查看已经安

  • 还在用nvm做node管理工具?快来试试Volta吧! 为什么会用Volta呢?因为这段时间电脑上的yarn出了问题,yarn install之后就报错There appears to be trouble with your network connection. Retrying...,期间找了很多方法都没有解决,但是今天用Volta安装了yarn之后居然奇迹般的可以下载了,速度还特别快。虽然

  • FROM https://github.com/creationix/nvm.git Table of Contents Installation Install script Verify installation Important Notes Git install Manual Install Manual upgrade Usage Long-term support Migrating

  • 安装Fish Shell brew install fish 安装Oh My Fish curl -L https://get.oh-my.fish | fish 安装Fisher curl https://git.io/fisher --create-dirs -sLo ~/.config/fish/functions/fisher.fish 配置 autojump clone autoju

 相关资料
  • fish 是适用于 Linux、macOS 的命令行 Shell,其名字取于"the friendly interactive shell"的简称,最大特点就是方便易用、功能强大、智能并且用户友好。很多其他 Shell 需要配置才有的功能,fish 默认提供,不需要任何配置。 主要特性 自动补全 支持丰富的 VGA 颜色 开箱即用 可搜索的命令历史 基于网页的配置功能 能够提升性能的内置命令

  • fish 是 OS X、Linux和家族其他成员的智能和友好的命令行shell。 它的特性有: 语法突出显示; 自动建立即时类型; 以及无需配置的标签功能。 fish 要求 C++ 11编译器,要想构建成功还需要 g++ 4.8 或更高版本,或clang 3.3或更高版本。 

  • Fish Redux 是一个基于 Redux 数据管理的组装式 Flutter 应用框架,它特别适用于构建中大型的复杂应用。 函数式编程 可预测的状态容器 可插拔组件化 无损性能 它的特点是配置式组装。一方面将一个大的页面,对视图和数据层拆解为互相独立的 Component|Adapter,上层负责组装,下层负责实现;另一方面将 Component|Adapter 拆分为 View、Reducer

  •   fish-ui 是基于vue2开发的一套ui组件库,其中css部分借鉴了semantic-ui的样式 demo: https://myliang.github.io/fish-ui/ github: https://github.com/myliang/fish-ui 安装 npm install less less-loader -Snpm install fish-ui -S  快速使用

  • Fish Sync 是一个文件同步工具,可在多个机器间传输多个目录。该工具不需要在每台机器上都安装,只需要发起初始同步的机器上安装即可。

  • Fish Fillets NG是一个益智游戏,目标是让两只鱼都安全通过关卡。注意:两只鱼都很容易受伤,比如一只鱼顶着一个物体而另一只鱼推此物体,将会杀死下面的哪只鱼,导致失败。 拥有78个关卡,原版Fish Fillets有70关,贡献者制作了8个新关卡和关卡编辑器。 Fish Fillets原来是ALTAR interactive.1998年发布的商业游戏,2002年放出为免费软件,2004年,