Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@serialport/list, @serialport/terminal requires 'package.json' to run #2972

Open
serg3295 opened this issue Dec 26, 2024 · 1 comment
Open

Comments

@serg3295
Copy link

SerialPort Version

13.0.0

Node Version

v20.18.1

Electron Version

No response

Platform

Linux Lenovo 6.8.0-51-generic #52-Ubuntu SMP PREEMPT_DYNAMIC Thu Dec 5 13:09:44 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Architecture

x64

Hardware or chipset of serialport

esp32, esp8266

What steps will reproduce the bug?

npx @serialport/terminal
npx @serialport/list

What happens?

Crash log
❯ npx @serialport/terminal
node:fs:448
  return binding.readFileUtf8(path, stringToFlags(options.flag));
                 ^

Error: ENOENT: no such file or directory, open '../package.json'
  at readFileSync (node:fs:448:20)
  at Object.<anonymous> (/home/serg/Projects/js/begin/node_modules/.pnpm/@serialport+terminal@13.0.0/node_modules/@serialport/terminal/dist/index.js:13:59)
  at Module._compile (node:internal/modules/cjs/loader:1469:14)
  at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
  at Module.load (node:internal/modules/cjs/loader:1288:32)
  at Module._load (node:internal/modules/cjs/loader:1104:12)
  at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:173:12)
  at node:internal/main/run_main_module:28:49 {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '../package.json'
}

Node.js v20.18.1

❯ npx @serialport/list
node:fs:448
  return binding.readFileUtf8(path, stringToFlags(options.flag));
                 ^

Error: ENOENT: no such file or directory, open '../package.json'
  at readFileSync (node:fs:448:20)
  at Object.<anonymous> (/home/serg/Projects/js/begin/node_modules/.pnpm/@serialport+list@13.0.0/node_modules/@serialport/list/dist/index.js:7:59)
  at Module._compile (node:internal/modules/cjs/loader:1469:14)
  at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
  at Module.load (node:internal/modules/cjs/loader:1288:32)
  at Module._load (node:internal/modules/cjs/loader:1104:12)
  at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:173:12)
  at node:internal/main/run_main_module:28:49 {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '../package.json'
}

❯ npx @serialport/repl
No arduinos found. You must specify a port to load.

For example:
      serialport-repl COM3
      serialport-repl /dev/tty.my-serialport

Node.js v20.18.1

What should have happened?

The @serialport/list, @serialport/terminal should run without additional 'package.json'

Additional information

I added package.json:

{
  "version": "0.1.0",
  "description": "testing"
}

the @serialport/list, @serialport/terminal started working.

@ebaauw
Copy link

ebaauw commented Jan 9, 2025

Problem is that package.json is now read using readFileSync(), which uses the current directory as base, instead of require(), which uses the programme directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants