serialport-tool 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +95 -6
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # Serialport Tool
2
2
 
3
- > 串口调试助手 Web 版 - 基于 Bun.js + serialport,浏览器端操作串口
3
+ > 串口调试助手 Web 版 - 基于 Node.js + serialport,浏览器端操作串口
4
4
 
5
- ![bun](https://img.shields.io/badge/Bun-1.0+-f9f1e1?logo=bun) ![license](https://img.shields.io/badge/license-MIT-green)
5
+ ![node](https://img.shields.io/badge/Node.js-18+-339933?logo=node.js) ![license](https://img.shields.io/badge/license-MIT-green)
6
6
 
7
7
  串口调试助手 Web 版:
8
- - 后端使用 **Bun.js** + `serialport` 库管理串口
8
+ - 后端使用 **Node.js** + `serialport` 库管理串口
9
9
  - 前端为纯 HTML/CSS/JS SPA,在浏览器中运行
10
10
  - 通过 WebSocket 实现实时串口数据收发
11
11
  - **启动时自动打开浏览器**访问对应地址
@@ -25,13 +25,13 @@
25
25
 
26
26
  ```bash
27
27
  # 安装依赖
28
- bun install
28
+ npm install
29
29
 
30
30
  # 启动 (自动打开浏览器)
31
- bun run start
31
+ npm start
32
32
 
33
33
  # 开发模式 (热重载)
34
- bun run dev
34
+ npm run dev
35
35
  ```
36
36
 
37
37
  启动后终端显示地址,浏览器会自动打开 `http://localhost:8765`。
@@ -138,6 +138,95 @@ sudo dseditgroup -o edit -a $(whoami) -t user _uucp
138
138
  sudo usermod -a -G dialout $(whoami)
139
139
  ```
140
140
 
141
+ ## 🚀 npm 发布记录与排障
142
+
143
+ 本项目首次发布到 npm 时遇到过以下问题,后续发版可按这个顺序检查。
144
+
145
+ ### 发布前检查
146
+
147
+ ```bash
148
+ # 构建
149
+ npm run build
150
+
151
+ # 查看即将发布的文件
152
+ npm pack --dry-run
153
+
154
+ # 确认当前登录账号
155
+ npm whoami
156
+
157
+ # 查看包名/版本是否已存在
158
+ npm view serialport-tool version
159
+ ```
160
+
161
+ `npm pack --dry-run` 应只包含运行所需文件,例如 `dist/`、`bin/`、`README.md`、`LICENSE` 和 `package.json`。
162
+
163
+ ### npm cache 权限问题
164
+
165
+ 如果遇到类似错误:
166
+
167
+ ```text
168
+ Your cache folder contains root-owned files
169
+ ```
170
+
171
+ 说明本机 `~/.npm` 里有 root 权限文件。可以临时指定一个可写 cache 目录绕过:
172
+
173
+ ```bash
174
+ npm --cache /private/tmp/serial_tool_npm_cache pack --dry-run
175
+ npm --cache /private/tmp/serial_tool_npm_cache publish --access public
176
+ ```
177
+
178
+ 也可以按 npm 提示修复 `~/.npm` 的文件所有权。
179
+
180
+ ### bin 字段路径问题
181
+
182
+ 发布时 npm 曾提示:
183
+
184
+ ```text
185
+ "bin[serialport-tool]" script name bin/cli.js was invalid and removed
186
+ ```
187
+
188
+ 原因是 `package.json` 中 `bin` 路径写成了 `./bin/cli.js`。应使用 npm 规范化后的写法:
189
+
190
+ ```json
191
+ {
192
+ "bin": {
193
+ "serialport-tool": "bin/cli.js"
194
+ }
195
+ }
196
+ ```
197
+
198
+ 如果不修复,发布后的包可能没有 `serialport-tool` 命令入口。
199
+
200
+ ### 2FA 与 token 问题
201
+
202
+ 如果发布时报错:
203
+
204
+ ```text
205
+ Two-factor authentication or granular access token with bypass 2fa enabled is required
206
+ ```
207
+
208
+ 需要在 npm 后台创建 granular access token,并确认:
209
+
210
+ - `Packages and scopes` 有目标包的权限,首次发布新包可选择 all packages
211
+ - 权限为 read and write
212
+ - 勾选 bypass two-factor authentication (2FA)
213
+
214
+ 推荐把 token 写入用户级 npm 配置,后续本机发布会自动使用:
215
+
216
+ ```bash
217
+ npm config set //registry.npmjs.org/:_authToken <npm_token> --location=user
218
+ ```
219
+
220
+ 不要把 token 写入项目仓库,也不要提交 `.npmrc`。如果 token 曾经暴露在聊天、日志或截图中,应在 npm 后台撤销后重新生成。
221
+
222
+ ### 首次发布命令
223
+
224
+ ```bash
225
+ npm publish --access public
226
+ ```
227
+
228
+ 如果已经持久化 token 到 `~/.npmrc`,直接运行上面的命令即可。
229
+
141
230
  ## 📝 License
142
231
 
143
232
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "serialport-tool",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "串口调试助手 Web 版 - 基于 Node.js + serialport,浏览器端操作串口",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",