node.js 使用serialport模块进行串口通信,解决file not found问题

本文主要介绍在Windows 10环境下,如何解决使用Node.js的serialport模块时遇到的'file not found'错误。关键步骤包括:全局安装serialport和node-gyp,确保VC++和Python版本正确,并在安装过程中注意不要更改默认路径。遇到版本不一致的问题,需手动修改模块文件中对应的版本号。

说正文之前,我真的很想说,这个模块很坑,而且windows更坑!

进入正题 : (只讲windows下如何使用)

1、安装模块:npm install serialport (全局安装请加 -g)

2、全局安装node-gyp:github地址:请一定跟着这个步骤走点击打开链接,安装时请注意,选项2的内容也必须安装,而且vc++必须使用默认安装路径,不可以更改安装路径,关于python必须安装2.7版,3.x版serialport模块会报错,python安装完了记得看一下环境变量是否添加。

3、使用命令行 进入到你安装serialport的地方 即:项目名称--> node_modules-->serialport 

node-gyp configure   //生成适当的项目构建文件

    如果此时你的vc++2015版没有检测出来,请输入命令行

 node-gyp configure --msvs_version = 2015

    然后

node-gyp build //预编译

      如果这一步报错说版本不一致,你根据报错提示的路径,看看你电脑里是多少版本的,然后根据报错的另一条路径找到模块文件里的文件,修改文件里的版本号就可以了。之后再次运行

4、现在你可以放心调用serialport模块了

 ps:如果你在安装时出了什么别的问题,随时留言,我会看到的



C:\Users\admin\Desktop\nature>npm install serialport@10.4.0 --verbose npm verbose cli C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js npm info using npm@11.6.2 npm info using node@v25.0.0 npm verbose title npm install serialport@10.4.0 npm verbose argv "install" "serialport@10.4.0" "--loglevel" "verbose" npm verbose logfile logs-max:10 dir:C:\Users\admin\AppData\Local\npm-cache\_logs\2025-11-28T09_14_41_662Z- npm verbose logfile C:\Users\admin\AppData\Local\npm-cache\_logs\2025-11-28T09_14_41_662Z-debug-0.log npm http fetch GET 200 https://registry.npmmirror.com/serialport 223ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/ws 96ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/bufferutil 31ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/utf-8-validate 52ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fbinding-mock 100ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/debug 131ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-cctalk 142ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-delimiter 145ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-packet-length 156ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-byte-length 159ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-spacepacket 161ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fbindings-cpp 165ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fstream 164ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-slip-encoder 176ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-readline 180ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-inter-byte-timeout 182ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-regex 200ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-ready 229ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/node-addon-api 37ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/node-gyp-build 61ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fbindings-interface 84ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fbindings-interface 86ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/ms 89ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fbindings-interface 95ms (cache miss) npm http cache @serialport/bindings-interface@https://registry.npmmirror.com/@serialport/bindings-interface/-/bindings-interface-1.2.2.tgz 0ms (cache hit) npm http cache ms@https://registry.npmmirror.com/ms/-/ms-2.1.3.tgz 0ms (cache hit) npm http cache node-gyp-build@https://registry.npmmirror.com/node-gyp-build/-/node-gyp-build-4.8.4.tgz 0ms (cache hit) npm http cache node-addon-api@https://registry.npmmirror.com/node-addon-api/-/node-addon-api-4.3.0.tgz 0ms (cache hit) npm http cache debug@https://registry.npmmirror.com/debug/-/debug-4.4.3.tgz 0ms (cache hit) npm http cache @serialport/stream@https://registry.npmmirror.com/@serialport/stream/-/stream-10.3.0.tgz 0ms (cache hit) npm http cache @serialport/parser-spacepacket@https://registry.npmmirror.com/@serialport/parser-spacepacket/-/parser-spacepacket-10.3.0.tgz 0ms (cache hit) npm http cache @serialport/parser-slip-encoder@https://registry.npmmirror.com/@serialport/parser-slip-encoder/-/parser-slip-encoder-10.3.0.tgz 0ms (cache hit) npm http cache @serialport/parser-regex@https://registry.npmmirror.com/@serialport/parser-regex/-/parser-regex-10.3.0.tgz 0ms (cache hit) npm http cache @serialport/parser-ready@https://registry.npmmirror.com/@serialport/parser-ready/-/parser-ready-10.3.0.tgz 0ms (cache hit) npm http cache @serialport/parser-readline@https://registry.npmmirror.com/@serialport/parser-readline/-/parser-readline-10.3.0.tgz 0ms (cache hit) npm http cache @serialport/parser-packet-length@https://registry.npmmirror.com/@serialport/parser-packet-length/-/parser-packet-length-10.3.0.tgz 0ms (cache hit) npm http cache @serialport/parser-inter-byte-timeout@https://registry.npmmirror.com/@serialport/parser-inter-byte-timeout/-/parser-inter-byte-timeout-10.3.0.tgz 0ms (cache hit) npm http cache @serialport/parser-cctalk@https://registry.npmmirror.com/@serialport/parser-cctalk/-/parser-cctalk-10.3.0.tgz 0ms (cache hit) npm http cache @serialport/parser-delimiter@https://registry.npmmirror.com/@serialport/parser-delimiter/-/parser-delimiter-10.3.0.tgz 0ms (cache hit) npm http cache @serialport/parser-byte-length@https://registry.npmmirror.com/@serialport/parser-byte-length/-/parser-byte-length-10.3.0.tgz 0ms (cache hit) npm http cache @serialport/binding-mock@https://registry.npmmirror.com/@serialport/binding-mock/-/binding-mock-10.2.2.tgz 0ms (cache hit) npm http cache @serialport/bindings-cpp@https://registry.npmmirror.com/@serialport/bindings-cpp/-/bindings-cpp-10.7.0.tgz 0ms (cache hit) npm http cache serialport@https://registry.npmmirror.com/serialport/-/serialport-10.4.0.tgz 0ms (cache hit) npm http cache ws@https://registry.npmmirror.com/ws/-/ws-8.18.3.tgz 0ms (cache hit) npm http cache @serialport/bindings-interface@https://registry.npmmirror.com/@serialport/bindings-interface/-/bindings-interface-1.2.1.tgz 0ms (cache hit) npm http cache @serialport/bindings-interface@https://registry.npmmirror.com/@serialport/bindings-interface/-/bindings-interface-1.2.1.tgz 0ms (cache hit) npm http fetch POST 404 https://registry.npmmirror.com/-/npm/v1/security/advisories/bulk 40ms npm verbose audit error HttpErrorGeneral: 404 Not Found - POST https://registry.npmmirror.com/-/npm/v1/security/advisories/bulk - [NOT_IMPLEMENTED] /-/npm/v1/security/* not implemented yet npm verbose audit error at C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-fetch\lib\check-response.js:103:15 npm verbose audit error at process.processTicksAndRejections (node:internal/process/task_queues:103:5) npm verbose audit error at async #getReport (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\audit-report.js:275:19) npm verbose audit error at async AuditReport.run (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\audit-report.js:100:19) { npm verbose audit error headers: [Object: null prototype] { npm verbose audit error server: [ 'Tengine' ], npm verbose audit error date: [ 'Fri, 28 Nov 2025 09:14:41 GMT' ], npm verbose audit error 'content-type': [ 'application/json' ], npm verbose audit error 'transfer-encoding': [ 'chunked' ], npm verbose audit error connection: [ 'keep-alive' ], npm verbose audit error 'strict-transport-security': [ 'max-age=5184000' ], npm verbose audit error via: [ 'kunlun3.cn7737[,404666]' ], npm verbose audit error 'timing-allow-origin': [ '*' ], npm verbose audit error eagleid: [ '7521a19717643212813718080e' ], npm verbose audit error 'x-fetch-attempts': [ '1' ] npm verbose audit error }, npm verbose audit error statusCode: 404, npm verbose audit error code: 'E404', npm verbose audit error method: 'POST', npm verbose audit error uri: 'https://registry.npmmirror.com/-/npm/v1/security/advisories/bulk', npm verbose audit error body: { npm verbose audit error error: '[NOT_IMPLEMENTED] /-/npm/v1/security/* not implemented yet' npm verbose audit error }, npm verbose audit error pkgid: undefined npm verbose audit error } npm http fetch GET 200 https://cdn.npmmirror.com/packages/%40serialport/bindings-interface/1.2.2/bindings-interface-1.2.2.tgz 181ms (cache miss) npm http fetch GET 200 https://cdn.npmmirror.com/packages/%40serialport/binding-mock/10.2.2/binding-mock-10.2.2.tgz 194ms (cache miss) npm http fetch GET 200 https://cdn.npmmirror.com/packages/%40serialport/stream/10.3.0/stream-10.3.0.tgz 212ms (cache miss) npm http fetch GET 200 https://cdn.npmmirror.com/packages/%40serialport/parser-regex/10.3.0/parser-regex-10.3.0.tgz 217ms (cache miss) npm http fetch GET 200 https://cdn.npmmirror.com/packages/ws/8.18.3/ws-8.18.3.tgz 233ms (cache miss) npm http fetch GET 200 https://cdn.npmmirror.com/packages/%40serialport/parser-delimiter/10.3.0/parser-delimiter-10.3.0.tgz 236ms (cache miss) npm http fetch GET 200 https://cdn.npmmirror.com/packages/%40serialport/parser-cctalk/10.3.0/parser-cctalk-10.3.0.tgz 248ms (cache miss) npm http fetch GET 200 https://cdn.npmmirror.com/packages/%40serialport/parser-spacepacket/10.3.0/parser-spacepacket-10.3.0.tgz 269ms (cache miss) npm http fetch GET 200 https://cdn.npmmirror.com/packages/%40serialport/parser-readline/10.3.0/parser-readline-10.3.0.tgz 270ms (cache miss) npm http fetch GET 200 https://cdn.npmmirror.com/packages/%40serialport/parser-packet-length/10.3.0/parser-packet-length-10.3.0.tgz 271ms (cache miss) npm http fetch GET 200 https://cdn.npmmirror.com/packages/%40serialport/parser-inter-byte-timeout/10.3.0/parser-inter-byte-timeout-10.3.0.tgz 280ms (cache miss) npm http fetch GET 200 https://cdn.npmmirror.com/packages/%40serialport/parser-ready/10.3.0/parser-ready-10.3.0.tgz 284ms (cache miss) npm http fetch GET 200 https://cdn.npmmirror.com/packages/%40serialport/parser-slip-encoder/10.3.0/parser-slip-encoder-10.3.0.tgz 291ms (cache miss) npm http fetch GET 200 https://cdn.npmmirror.com/packages/%40serialport/bindings-interface/1.2.1/bindings-interface-1.2.1.tgz 300ms (cache miss) npm http fetch GET 200 https://cdn.npmmirror.com/packages/%40serialport/bindings-interface/1.2.1/bindings-interface-1.2.1.tgz 302ms (cache miss) npm http fetch GET 200 https://cdn.npmmirror.com/packages/%40serialport/parser-byte-length/10.3.0/parser-byte-length-10.3.0.tgz 316ms (cache miss) npm http fetch GET 200 https://cdn.npmmirror.com/packages/node-addon-api/4.3.0/node-addon-api-4.3.0.tgz 354ms (cache miss) npm http fetch GET 200 https://cdn.npmmirror.com/packages/%40serialport/bindings-cpp/10.7.0/bindings-cpp-10.7.0.tgz 514ms (cache miss) npm http fetch GET 200 https://cdn.npmmirror.com/packages/serialport/10.4.0/serialport-10.4.0.tgz 615ms (cache miss) npm info run @serialport/bindings-cpp@10.7.0 install node_modules/@serialport/bindings-cpp node-gyp-build npm info run @serialport/bindings-cpp@10.7.0 install { code: 0, signal: null } added 22 packages in 2s 12 packages are looking for funding run `npm fund` for details npm verbose cwd C:\Users\admin\Desktop\nature npm verbose os Windows_NT 10.0.26100 npm verbose node v25.0.0 npm verbose npm v11.6.2 npm verbose exit 0 npm info ok C:\Users\admin\Desktop\nature>
11-29
C:\Users\admin\Desktop\nature>rmdir /s /q node_modules C:\Users\admin\Desktop\nature>del package-lock.json C:\Users\admin\Desktop\nature>npm install serialport@10.4.0 --verbose npm verb cli C:\nvm4w\nodejs\node.exe C:\nvm4w\nodejs\node_modules\npm\bin\npm-cli.js npm info using npm@8.19.3 npm info using node@v16.19.1 npm timing npm:load:whichnode Completed in 1ms npm timing config:load:defaults Completed in 1ms npm timing config:load:file:C:\Users\admin\AppData\Local\nvm\v16.19.1\node_modules\npm\npmrc Completed in 1ms npm timing config:load:builtin Completed in 1ms npm timing config:load:cli Completed in 1ms npm timing config:load:env Completed in 1ms npm timing config:load:file:C:\Users\admin\Desktop\nature\.npmrc Completed in 0ms npm timing config:load:project Completed in 10ms npm timing config:load:file:C:\Users\admin\.npmrc Completed in 1ms npm timing config:load:user Completed in 1ms npm timing config:load:file:C:\nvm4w\nodejs\etc\npmrc Completed in 0ms npm timing config:load:global Completed in 0ms npm timing config:load:validate Completed in 1ms npm timing config:load:credentials Completed in 1ms npm timing config:load:setEnvs Completed in 1ms npm timing config:load Completed in 18ms npm timing npm:load:configload Completed in 18ms npm timing npm:load:mkdirpcache Completed in 0ms npm timing npm:load:mkdirplogs Completed in 1ms npm verb title npm install serialport@10.4.0 npm verb argv "install" "serialport@10.4.0" "--loglevel" "verbose" npm timing npm:load:setTitle Completed in 1ms npm timing config:load:flatten Completed in 2ms npm timing npm:load:display Completed in 8ms npm verb logfile logs-max:10 dir:C:\Users\admin\AppData\Local\npm-cache\_logs npm verb logfile C:\Users\admin\AppData\Local\npm-cache\_logs\2025-11-28T09_22_54_627Z-debug-0.log npm timing npm:load:logFile Completed in 14ms npm timing npm:load:timers Completed in 0ms npm timing npm:load:configScope Completed in 0ms npm timing npm:load Completed in 44ms npm timing arborist:ctor Completed in 0ms npm timing arborist:ctor Completed in 0ms npm timing idealTree:init Completed in 10ms npm timing idealTree:userRequests Completed in 2ms npm http fetch GET 200 https://registry.npmmirror.com/serialport 184ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/ws 61ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/bufferutil 42ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/utf-8-validate 44ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/debug 139ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-inter-byte-timeout 154ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-spacepacket 162ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-packet-length 164ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-delimiter 166ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fbinding-mock 180ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fstream 182ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-ready 185ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-cctalk 192ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-regex 193ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-readline 212ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fbindings-cpp 223ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-byte-length 233ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-slip-encoder 272ms (cache miss) npm timing idealTree:#root Completed in 624ms npm http fetch GET 200 https://registry.npmmirror.com/ms 72ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/node-addon-api 77ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/node-gyp-build 84ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fbindings-interface 154ms (cache miss) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fbindings-interface 155ms (cache miss) npm timing idealTree:node_modules/serialport Completed in 176ms npm timing idealTree:node_modules/@serialport/binding-mock Completed in 2ms npm timing idealTree:node_modules/@serialport/bindings-cpp Completed in 4ms npm timing idealTree:node_modules/@serialport/bindings-interface Completed in 0ms npm timing idealTree:node_modules/@serialport/parser-byte-length Completed in 0ms npm timing idealTree:node_modules/@serialport/parser-cctalk Completed in 0ms npm timing idealTree:node_modules/@serialport/parser-delimiter Completed in 0ms npm timing idealTree:node_modules/@serialport/parser-inter-byte-timeout Completed in 0ms npm timing idealTree:node_modules/@serialport/parser-packet-length Completed in 0ms npm timing idealTree:node_modules/@serialport/parser-readline Completed in 0ms npm timing idealTree:node_modules/@serialport/parser-ready Completed in 0ms npm timing idealTree:node_modules/@serialport/parser-regex Completed in 0ms npm timing idealTree:node_modules/@serialport/parser-slip-encoder Completed in 0ms npm timing idealTree:node_modules/@serialport/parser-spacepacket Completed in 0ms npm timing idealTree:node_modules/@serialport/stream Completed in 1ms npm timing idealTree:node_modules/debug Completed in 1ms npm timing idealTree:node_modules/ms Completed in 0ms npm timing idealTree:node_modules/node-addon-api Completed in 0ms npm timing idealTree:node_modules/node-gyp-build Completed in 0ms npm timing idealTree:node_modules/ws Completed in 0ms npm timing idealTree:node_modules/@serialport/bindings-cpp/node_modules/@serialport/bindings-interface Completed in 0ms npm timing idealTree:node_modules/@serialport/stream/node_modules/@serialport/bindings-interface Completed in 0ms npm timing idealTree:buildDeps Completed in 813ms npm timing idealTree:fixDepFlags Completed in 1ms npm timing idealTree Completed in 829ms npm timing reify:loadTrees Completed in 830ms npm timing reify:diffTrees Completed in 2ms npm timing reify:retireShallow Completed in 1ms npm timing reify:createSparse Completed in 11ms npm timing reify:loadBundles Completed in 0ms npm http fetch POST 404 https://registry.npmmirror.com/-/npm/v1/security/advisories/bulk 28ms npm http fetch POST 404 https://registry.npmmirror.com/-/npm/v1/security/audits/quick 16ms npm verb audit error HttpErrorGeneral: 404 Not Found - POST https://registry.npmmirror.com/-/npm/v1/security/audits/quick - [NOT_IMPLEMENTED] /-/npm/v1/security/* not implemented yet npm verb audit error at C:\Users\admin\AppData\Local\nvm\v16.19.1\node_modules\npm\node_modules\npm-registry-fetch\lib\check-response.js:95:15 npm verb audit error at processTicksAndRejections (node:internal/process/task_queues:96:5) npm verb audit error at async Map.[getReport] (C:\Users\admin\AppData\Local\nvm\v16.19.1\node_modules\npm\node_modules\@npmcli\arborist\lib\audit-report.js:335:21) npm verb audit error at async Map.run (C:\Users\admin\AppData\Local\nvm\v16.19.1\node_modules\npm\node_modules\@npmcli\arborist\lib\audit-report.js:106:19) npm verb audit error HttpErrorGeneral: 404 Not Found - POST https://registry.npmmirror.com/-/npm/v1/security/audits/quick - [NOT_IMPLEMENTED] /-/npm/v1/security/* not implemented yet npm verb audit error at C:\Users\admin\AppData\Local\nvm\v16.19.1\node_modules\npm\node_modules\npm-registry-fetch\lib\check-response.js:95:15 npm verb audit error at processTicksAndRejections (node:internal/process/task_queues:96:5) npm verb audit error at async Map.[getReport] (C:\Users\admin\AppData\Local\nvm\v16.19.1\node_modules\npm\node_modules\@npmcli\arborist\lib\audit-report.js:335:21) npm verb audit error at async Map.run (C:\Users\admin\AppData\Local\nvm\v16.19.1\node_modules\npm\node_modules\@npmcli\arborist\lib\audit-report.js:106:19) { npm verb audit error headers: [Object: null prototype] { npm verb audit error server: [ 'Tengine' ], npm verb audit error date: [ 'Fri, 28 Nov 2025 09:22:54 GMT' ], npm verb audit error 'content-type': [ 'application/json' ], npm verb audit error 'transfer-encoding': [ 'chunked' ], npm verb audit error connection: [ 'keep-alive' ], npm verb audit error 'strict-transport-security': [ 'max-age=5184000' ], npm verb audit error via: [ 'kunlun7.cn5212[,404666]' ], npm verb audit error 'timing-allow-origin': [ '*' ], npm verb audit error eagleid: [ '7ae4df1b17643217741033733e' ], npm verb audit error 'x-fetch-attempts': [ '1' ] npm verb audit error }, npm verb audit error statusCode: 404, npm verb audit error code: 'E404', npm verb audit error method: 'POST', npm verb audit error uri: 'https://registry.npmmirror.com/-/npm/v1/security/audits/quick', npm verb audit error body: { npm verb audit error error: '[NOT_IMPLEMENTED] /-/npm/v1/security/* not implemented yet' npm verb audit error }, npm verb audit error pkgid: undefined npm verb audit error } npm timing auditReport:getReport Completed in 59ms npm timing reify:audit Completed in 59ms npm timing reifyNode:node_modules/ms Completed in 105ms npm timing reifyNode:node_modules/@serialport/parser-regex Completed in 108ms npm timing reifyNode:node_modules/@serialport/parser-readline Completed in 108ms npm timing reifyNode:node_modules/@serialport/parser-packet-length Completed in 109ms npm timing reifyNode:node_modules/@serialport/parser-inter-byte-timeout Completed in 109ms npm timing reifyNode:node_modules/@serialport/parser-delimiter Completed in 110ms npm timing reifyNode:node_modules/@serialport/parser-cctalk Completed in 111ms npm timing reifyNode:node_modules/@serialport/parser-ready Completed in 111ms npm timing reifyNode:node_modules/@serialport/parser-byte-length Completed in 112ms npm timing reifyNode:node_modules/@serialport/stream Completed in 114ms npm timing reifyNode:node_modules/@serialport/bindings-interface Completed in 116ms npm timing reifyNode:node_modules/@serialport/parser-spacepacket Completed in 116ms npm timing reifyNode:node_modules/debug Completed in 117ms npm timing reifyNode:node_modules/@serialport/bindings-cpp/node_modules/@serialport/bindings-interface Completed in 117ms npm timing reifyNode:node_modules/@serialport/binding-mock Completed in 117ms npm timing reifyNode:node_modules/@serialport/stream/node_modules/@serialport/bindings-interface Completed in 119ms npm timing reifyNode:node_modules/node-gyp-build Completed in 120ms npm timing reifyNode:node_modules/@serialport/parser-slip-encoder Completed in 120ms npm timing reifyNode:node_modules/serialport Completed in 121ms npm timing reifyNode:node_modules/ws Completed in 131ms npm timing reifyNode:node_modules/node-addon-api Completed in 134ms npm timing reifyNode:node_modules/@serialport/bindings-cpp Completed in 197ms npm timing reify:unpack Completed in 198ms npm timing reify:unretire Completed in 1ms npm timing build:queue Completed in 10ms npm timing build:link:node_modules/node-gyp-build Completed in 24ms npm timing build:link Completed in 26ms npm info run @serialport/bindings-cpp@10.7.0 install node_modules/@serialport/bindings-cpp node-gyp-build npm info run @serialport/bindings-cpp@10.7.0 install { code: 0, signal: null } npm timing build:run:install:node_modules/@serialport/bindings-cpp Completed in 258ms npm timing build:run:install Completed in 258ms npm timing build:deps Completed in 295ms npm timing build Completed in 295ms npm timing reify:build Completed in 295ms npm timing reify:trash Completed in 0ms npm timing reify:save Completed in 6ms npm timing reify Completed in 1360ms added 22 packages in 2s 12 packages are looking for funding run `npm fund` for details npm timing command:install Completed in 1364ms npm verb exit 0 npm timing npm Completed in 1535ms npm info ok C:\Users\admin\Desktop\nature>dir node_modules\@serialport\bindings-cpp\build\Release\bindings.node 系统找不到指定的路径。 C:\Users\admin\Desktop\nature>
11-29
Microsoft Windows [版本 10.0.26100.6899] (c) Microsoft Corporation。保留所有权利。 C:\Users\admin>python -c "import distutils; print('OK')" OK C:\Users\admin>npm config set python python C:\Users\admin>cd C:\Users\admin\Desktop\nature C:\Users\admin\Desktop\nature> C:\Users\admin\Desktop\nature>rmdir /s /q node_modules 系统找不到指定的文件。 C:\Users\admin\Desktop\nature>del package-lock.json 找不到 C:\Users\admin\Desktop\nature\package-lock.json C:\Users\admin\Desktop\nature> C:\Users\admin\Desktop\nature>npm install serialport@10.4.0 --build-from-source --verbose npm verb cli C:\nvm4w\nodejs\node.exe C:\nvm4w\nodejs\node_modules\npm\bin\npm-cli.js npm info using npm@8.19.3 npm info using node@v16.19.1 npm timing npm:load:whichnode Completed in 1ms npm timing config:load:defaults Completed in 1ms npm timing config:load:file:C:\Users\admin\AppData\Local\nvm\v16.19.1\node_modules\npm\npmrc Completed in 1ms npm timing config:load:builtin Completed in 1ms npm timing config:load:cli Completed in 2ms npm timing config:load:env Completed in 0ms npm timing config:load:file:C:\Users\admin\Desktop\nature\.npmrc Completed in 0ms npm timing config:load:project Completed in 3ms npm timing config:load:file:C:\Users\admin\.npmrc Completed in 1ms npm timing config:load:user Completed in 1ms npm timing config:load:file:C:\nvm4w\nodejs\etc\npmrc Completed in 0ms npm timing config:load:global Completed in 0ms npm timing config:load:validate Completed in 1ms npm timing config:load:credentials Completed in 0ms npm timing config:load:setEnvs Completed in 1ms npm timing config:load Completed in 10ms npm timing npm:load:configload Completed in 10ms npm timing npm:load:mkdirpcache Completed in 1ms npm timing npm:load:mkdirplogs Completed in 0ms npm verb title npm install serialport@10.4.0 npm verb argv "install" "serialport@10.4.0" "--build-from-source" "--loglevel" "verbose" npm timing npm:load:setTitle Completed in 1ms npm timing config:load:flatten Completed in 2ms npm timing npm:load:display Completed in 10ms npm verb logfile logs-max:10 dir:C:\Users\admin\AppData\Local\npm-cache\_logs npm verb logfile C:\Users\admin\AppData\Local\npm-cache\_logs\2025-11-28T09_53_53_710Z-debug-0.log npm timing npm:load:logFile Completed in 8ms npm timing npm:load:timers Completed in 0ms npm timing npm:load:configScope Completed in 0ms npm timing npm:load Completed in 32ms npm timing arborist:ctor Completed in 0ms npm timing arborist:ctor Completed in 0ms npm timing idealTree:init Completed in 10ms npm timing idealTree:userRequests Completed in 2ms npm http fetch GET 200 https://registry.npmmirror.com/serialport 124ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/ws 25ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/bufferutil 31ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/utf-8-validate 34ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/debug 86ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-inter-byte-timeout 109ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fbindings-cpp 111ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-spacepacket 117ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-cctalk 121ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-packet-length 123ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-readline 123ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fbinding-mock 127ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-ready 127ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-slip-encoder 137ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-delimiter 191ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fstream 304ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-regex 507ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fparser-byte-length 510ms (cache revalidated) npm timing idealTree:#root Completed in 743ms npm http fetch GET 200 https://registry.npmmirror.com/node-addon-api 26ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/ms 28ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/node-gyp-build 36ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fbindings-interface 154ms (cache revalidated) npm http fetch GET 200 https://registry.npmmirror.com/@serialport%2fbindings-interface 155ms (cache revalidated) npm timing idealTree:node_modules/serialport Completed in 177ms npm timing idealTree:node_modules/@serialport/binding-mock Completed in 2ms npm timing idealTree:node_modules/@serialport/bindings-cpp Completed in 6ms npm timing idealTree:node_modules/@serialport/bindings-interface Completed in 0ms npm timing idealTree:node_modules/@serialport/parser-byte-length Completed in 0ms npm timing idealTree:node_modules/@serialport/parser-cctalk Completed in 0ms npm timing idealTree:node_modules/@serialport/parser-delimiter Completed in 0ms npm timing idealTree:node_modules/@serialport/parser-inter-byte-timeout Completed in 0ms npm timing idealTree:node_modules/@serialport/parser-packet-length Completed in 0ms npm timing idealTree:node_modules/@serialport/parser-readline Completed in 0ms npm timing idealTree:node_modules/@serialport/parser-ready Completed in 0ms npm timing idealTree:node_modules/@serialport/parser-regex Completed in 0ms npm timing idealTree:node_modules/@serialport/parser-slip-encoder Completed in 0ms npm timing idealTree:node_modules/@serialport/parser-spacepacket Completed in 0ms npm timing idealTree:node_modules/@serialport/stream Completed in 1ms npm timing idealTree:node_modules/debug Completed in 0ms npm timing idealTree:node_modules/ms Completed in 0ms npm timing idealTree:node_modules/node-addon-api Completed in 0ms npm timing idealTree:node_modules/node-gyp-build Completed in 0ms npm timing idealTree:node_modules/ws Completed in 0ms npm timing idealTree:node_modules/@serialport/bindings-cpp/node_modules/@serialport/bindings-interface Completed in 1ms npm timing idealTree:node_modules/@serialport/stream/node_modules/@serialport/bindings-interface Completed in 0ms npm timing idealTree:buildDeps Completed in 936ms npm timing idealTree:fixDepFlags Completed in 1ms npm timing idealTree Completed in 952ms npm timing reify:loadTrees Completed in 953ms npm timing reify:diffTrees Completed in 1ms npm timing reify:retireShallow Completed in 1ms npm timing reify:createSparse Completed in 10ms npm timing reify:loadBundles Completed in 0ms npm http fetch POST 404 https://registry.npmmirror.com/-/npm/v1/security/advisories/bulk 45ms npm http fetch POST 404 https://registry.npmmirror.com/-/npm/v1/security/audits/quick 17ms npm verb audit error HttpErrorGeneral: 404 Not Found - POST https://registry.npmmirror.com/-/npm/v1/security/audits/quick - [NOT_IMPLEMENTED] /-/npm/v1/security/* not implemented yet npm verb audit error at C:\Users\admin\AppData\Local\nvm\v16.19.1\node_modules\npm\node_modules\npm-registry-fetch\lib\check-response.js:95:15 npm verb audit error at processTicksAndRejections (node:internal/process/task_queues:96:5) npm verb audit error at async Map.[getReport] (C:\Users\admin\AppData\Local\nvm\v16.19.1\node_modules\npm\node_modules\@npmcli\arborist\lib\audit-report.js:335:21) npm verb audit error at async Map.run (C:\Users\admin\AppData\Local\nvm\v16.19.1\node_modules\npm\node_modules\@npmcli\arborist\lib\audit-report.js:106:19) npm verb audit error HttpErrorGeneral: 404 Not Found - POST https://registry.npmmirror.com/-/npm/v1/security/audits/quick - [NOT_IMPLEMENTED] /-/npm/v1/security/* not implemented yet npm verb audit error at C:\Users\admin\AppData\Local\nvm\v16.19.1\node_modules\npm\node_modules\npm-registry-fetch\lib\check-response.js:95:15 npm verb audit error at processTicksAndRejections (node:internal/process/task_queues:96:5) npm verb audit error at async Map.[getReport] (C:\Users\admin\AppData\Local\nvm\v16.19.1\node_modules\npm\node_modules\@npmcli\arborist\lib\audit-report.js:335:21) npm verb audit error at async Map.run (C:\Users\admin\AppData\Local\nvm\v16.19.1\node_modules\npm\node_modules\@npmcli\arborist\lib\audit-report.js:106:19) { npm verb audit error headers: [Object: null prototype] { npm verb audit error server: [ 'Tengine' ], npm verb audit error date: [ 'Fri, 28 Nov 2025 09:53:53 GMT' ], npm verb audit error 'content-type': [ 'application/json' ], npm verb audit error 'transfer-encoding': [ 'chunked' ], npm verb audit error connection: [ 'keep-alive' ], npm verb audit error 'strict-transport-security': [ 'max-age=5184000' ], npm verb audit error via: [ 'kunlun2.cn8358[,404666]' ], npm verb audit error 'timing-allow-origin': [ '*' ], npm verb audit error eagleid: [ '7544591617643236332911615e' ], npm verb audit error 'x-fetch-attempts': [ '1' ] npm verb audit error }, npm verb audit error statusCode: 404, npm verb audit error code: 'E404', npm verb audit error method: 'POST', npm verb audit error uri: 'https://registry.npmmirror.com/-/npm/v1/security/audits/quick', npm verb audit error body: { npm verb audit error error: '[NOT_IMPLEMENTED] /-/npm/v1/security/* not implemented yet' npm verb audit error }, npm verb audit error pkgid: undefined npm verb audit error } npm timing auditReport:getReport Completed in 77ms npm timing reify:audit Completed in 78ms npm timing reifyNode:node_modules/ms Completed in 94ms npm timing reifyNode:node_modules/@serialport/parser-ready Completed in 100ms npm timing reifyNode:node_modules/@serialport/parser-packet-length Completed in 101ms npm timing reifyNode:node_modules/@serialport/parser-readline Completed in 101ms npm timing reifyNode:node_modules/@serialport/parser-byte-length Completed in 100ms npm timing reifyNode:node_modules/@serialport/parser-inter-byte-timeout Completed in 103ms npm timing reifyNode:node_modules/@serialport/parser-regex Completed in 103ms npm timing reifyNode:node_modules/@serialport/parser-cctalk Completed in 103ms npm timing reifyNode:node_modules/@serialport/parser-delimiter Completed in 103ms npm timing reifyNode:node_modules/@serialport/stream Completed in 105ms npm timing reifyNode:node_modules/@serialport/parser-spacepacket Completed in 110ms npm timing reifyNode:node_modules/@serialport/bindings-interface Completed in 110ms npm timing reifyNode:node_modules/@serialport/bindings-cpp/node_modules/@serialport/bindings-interface Completed in 110ms npm timing reifyNode:node_modules/@serialport/binding-mock Completed in 110ms npm timing reifyNode:node_modules/@serialport/stream/node_modules/@serialport/bindings-interface Completed in 112ms npm timing reifyNode:node_modules/debug Completed in 112ms npm timing reifyNode:node_modules/node-gyp-build Completed in 115ms npm timing reifyNode:node_modules/@serialport/parser-slip-encoder Completed in 120ms npm timing reifyNode:node_modules/serialport Completed in 120ms npm timing reifyNode:node_modules/ws Completed in 162ms npm timing reifyNode:node_modules/node-addon-api Completed in 170ms npm timing reifyNode:node_modules/@serialport/bindings-cpp Completed in 257ms npm timing reify:unpack Completed in 258ms npm timing reify:unretire Completed in 0ms npm timing build:queue Completed in 2ms npm timing build:link:node_modules/node-gyp-build Completed in 19ms npm timing build:link Completed in 19ms npm info run @serialport/bindings-cpp@10.7.0 install node_modules/@serialport/bindings-cpp node-gyp-build npm info run @serialport/bindings-cpp@10.7.0 install { code: 0, signal: null } npm timing build:run:install:node_modules/@serialport/bindings-cpp Completed in 6904ms npm timing build:run:install Completed in 6906ms npm timing build:deps Completed in 6927ms npm timing build Completed in 6927ms npm timing reify:build Completed in 6928ms npm timing reify:trash Completed in 0ms npm timing reify:save Completed in 7ms npm timing reify Completed in 8178ms added 22 packages in 8s 12 packages are looking for funding run `npm fund` for details npm timing command:install Completed in 8183ms npm verb exit 0 npm timing npm Completed in 8342ms npm info ok C:\Users\admin\Desktop\nature>
11-29
C:\Users\admin\Desktop\nature>echo const SerialPort = require('serialport^); > test.js C:\Users\admin\Desktop\nature>echo SerialPort.list^(^).then^(ports => { >> test.js C:\Users\admin\Desktop\nature>echo console.log^('🔍 检测到以下串口设备:'^); >> test.js C:\Users\admin\Desktop\nature>echo if ^(ports.length === 0^) { >> test.js C:\Users\admin\Desktop\nature>echo console.log^(' 📵 未发现任何串口设备,请插入 USB 转串口模块或单片机再试。'^); >> test.js C:\Users\admin\Desktop\nature>echo } else { >> test.js C:\Users\admin\Desktop\nature>echo ports.forEach^(port => { >> test.js C:\Users\admin\Desktop\nature>echo console.log^(` 📲 ${port.path}`^); >> test.js C:\Users\admin\Desktop\nature>echo console.log^(` PID: ${port.productId || 'N/A'}`^); >> test.js console.log(` PID: ${port.productId C:\Users\admin\Desktop\nature>echo console.log^(` VID: ${port.vendorId || 'N/A'}`^); >> test.js console.log(` VID: ${port.vendorId C:\Users\admin\Desktop\nature>echo console.log^(` 制造商: ${port.manufacturer || 'Unknown'}`^); >> test.js console.log(` 制造商: ${port.manufacturer C:\Users\admin\Desktop\nature>echo }^); >> test.js C:\Users\admin\Desktop\nature>echo } >> test.js C:\Users\admin\Desktop\nature>echo }^).catch^(err => { >> test.js C:\Users\admin\Desktop\nature>echo console.error^('❌ 获取串口列表失败:', err.message^); >> test.js C:\Users\admin\Desktop\nature>echo }^); >> test.js C:\Users\admin\Desktop\nature>node test.js node:internal/modules/cjs/loader:1024 throw err; ^ Error: Cannot find module 'test.js' at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1021:15) at Function.Module._load (node:internal/modules/cjs/loader:866:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:22:47 { code: 'MODULE_NOT_FOUND', requireStack: [] } C:\Users\admin\Desktop\nature>
最新发布
11-29
评论 9
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值