npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

local-file-picker

v0.1.7

Published

Vue 3 file/directory picker modal backed by a Node.js Express middleware. Returns absolute paths from the local filesystem.

Downloads

1,793

Readme

file-picker-node

基于 Vue 3 + Express 的本地文件 / 目录选择器,通过 Node.js 后端直接读取文件系统,可获取绝对路径

npm version license

功能特性

  • 📄 选择文件 / 文件夹 — 可多选,返回本地绝对路径
  • 🔍 全局搜索 — 支持索引搜索(快)和实时遍历降级搜索
  • 📍 面包屑导航 — 路径导航,支持快捷访问家目录、桌面、文档等
  • 💾 盘符列表 — Windows 多盘符支持
  • 多选 — Ctrl/Cmd + 点击多选
  • SQLite 索引 — 后台建立文件索引,全局搜索毫秒级响应

适用于本地工具、内部后台、Electron 应用等场景,不适合部署到公网(服务端直接读取宿主机文件系统)。


安装

npm install file-picker-node

快速上手

第一步:后端挂载中间件

在你的 Express 应用中挂载 file-picker 中间件:

// server.js
import express from 'express';
import cors from 'cors';
import { createFilePickerMiddleware } from 'file-picker-node';

const app = express();
app.use(cors());
app.use(express.json());

// 将所有 /api/fs/* 路由交给中间件处理
app.use('/api', createFilePickerMiddleware());

app.listen(3000, () => console.log('Server running on http://localhost:3000'));

中间件选项

app.use('/api', createFilePickerMiddleware({
  // SQLite 索引数据库路径(默认 ~/.file-picker-index.db)
  dbPath: '/custom/path/index.db',

  // 建立索引时跳过的目录名(Set 或 Array)
  skipDirs: new Set(['node_modules', '.git', 'dist']),

  // 是否强制重建索引(默认读取 FORCE_REINDEX 环境变量)
  forceReindex: false,
}));

第二步:前端使用 Vue 组件

安装后构建产物引入

// main.js 或按需引入
import { FilePickerModal } from 'file-picker-node/client';
import 'file-picker-node/dist/file-picker.css'; // 引入样式

组件用法

<template>
  <button @click="open = true">选择文件</button>

  <FilePickerModal
    :visible="open"
    mode="file"
    api-base="http://localhost:3000/api"
    @close="open = false"
    @confirm="onConfirm"
  />
</template>

<script setup>
import { ref } from 'vue';
import { FilePickerModal } from 'file-picker-node/client';
import 'file-picker-node/dist/file-picker.css';

const open = ref(false);

function onConfirm(paths) {
  // paths 是选中路径的数组,如 ['C:\\Users\\xuze\\Documents\\report.pdf']
  console.log('选中文件:', paths);
  open.value = false;
}
</script>

组件 Props

| Prop | 类型 | 默认值 | 说明 | | ---------- | --------- | -------- | ------------------------------------------------ | | visible | Boolean | false | 是否显示弹窗 | | mode | String | 'file' | 'file' 选文件 / 'directory' 选文件夹 | | api-base | String | '/api' | 后端 API 基础路径,如 'http://localhost:3000/api' |

组件 Events

| Event | 参数 | 说明 | | --------- | --------------- | ---------------------------- | | close | — | 弹窗关闭(取消或点击背景) | | confirm | paths: string[] | 用户点击确认,携带选中路径 |


API 接口说明

中间件挂载后提供以下接口(以挂载在 /api 为例):

| 方法 | 路径 | 说明 | | ------ | --------------------- | ---------------------------------------- | | GET | /api/health | 健康检查 + 索引状态 | | GET | /api/fs/home | 获取用户家目录路径 | | GET | /api/fs/drives | 获取磁盘列表(Windows 盘符 / Linux /) | | GET | /api/fs/list | 列出目录内容 ?dir=路径 | | GET | /api/fs/search | 全局搜索 ?q=关键词&mode=file\|directory\|all&limit=200 | | GET | /api/fs/index-status| 索引进度状态 | | POST | /api/fs/reindex | 触发重建索引 |


本地开发 Demo

git clone https://github.com/xuze/file-picker-node.git
cd file-picker-node
npm install
npm run dev:server   # 后端 http://localhost:8642
npm run dev:client   # 前端 http://localhost:7891

或一键启动:

npm run dev

构建发布包

npm run build
# 输出 dist/file-picker.mjs 和 dist/file-picker.css

发布到 npm:

npm publish

技术栈

| 层 | 技术 | 版本 | | ------ | --------------- | ------- | | 前端 | Vue 3 + Vite | 3.5 / 7 | | 后端 | Express | 5.x | | 索引 | Node SQLite | 内置 |


License

MIT © 2026 xuze

快速启动

# 1. 安装后端依赖
cd server && npm install

# 2. 安装前端依赖
cd ../client && npm install

# 3. 启动后端(端口 8642)
cd ../server && npm run dev

# 4. 启动前端(端口 7891)— 另开终端
cd client && npm run dev

然后在浏览器打开 http://localhost:7891

端口说明

| 服务 | 端口 | | ---- | ---- | | 前端 | 7891 | | 后端 | 8642 |

API 端点

| 方法 | 路径 | 说明 | | ---- | --------------- | --------------------------- | | GET | /api/health | 健康检查 | | GET | /api/fs/home | 获取用户家目录路径 | | GET | /api/fs/drives | 获取可用磁盘盘符列表 | | GET | /api/fs/list | 列出目录内容 (?dir=xxx) |