SocketDev / SocketDev/socket-cli

socket npm run build crashes with ERR_MISSING_OPTION: --permission on Node v24 + Next.js

Đang mở Phù hợp với người mới
#1,160 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

bug
Ngôn ngữ chính
TypeScript
Star
317
Fork
65
Merge trung bình
1 giờ 26 phút
Pull request đã merge (30 ngày)
30

Mô tả

Description

socket npm run build crashes during Next.js's TypeScript checking phase on Node v24. Running npm run build directly works fine.

Root cause

In shadow-npm-bin2.js:67, the --node-options value is wrapped in literal single quotes:

`--node-options='${...}${utils.cmdFlagsToString(permArgs)}'`

Since this argument is passed via child_process.spawn() (no shell), the quotes are not interpreted — npm receives them as part of the value and sets:

NODE_OPTIONS='--permission --allow-child-process --allow-fs-read=* --allow-fs-write=...'

Node.js silently ignores the garbled tokens. However, Next.js re-parses NODE_OPTIONS for its build workers using a tokenizer that splits on whitespace and only handles " as string delimiters, not '. This causes:

  • '--permission (leading ') → unrecognized, dropped
  • --allow-child-process, --allow-fs-read=*, --allow-fs-write=... → valid, kept

The TypeScript worker then receives --allow-* flags without --permission, and Node v24 throws ERR_MISSING_OPTION.

Suggested fix

Remove the single quotes — they are unnecessary and harmful when arguments are passed via spawn():

- `--node-options='${nodeOptionsArg ? nodeOptionsArg.slice(15) : ''}${utils.cmdFlagsToString(permArgs)}'`
+ `--node-options=${nodeOptionsArg ? nodeOptionsArg.slice(15) : ''}${utils.cmdFlagsToString(permArgs)}`
Repro
  • Node v24.11.1, Next.js 16.2.1, Socket CLI 1.1.78 (also 1.1.76)
  • npm run build → succeeds
  • socket npm run build → crashes at "Running TypeScript ..."
TypeError [ERR_MISSING_OPTION]: --permission is required
    at node:internal/process/pre_execution:656:15
    at Array.forEach (<anonymous>)
    at initializePermission (node:internal/process/pre_execution:653:5)
Related
  • #1036 — a separate bug on the same line where user-set NODE_OPTIONS are replaced rather than merged

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Kiểm tra shadow-npm-bin2.js quanh dòng 67 và tái hiện lỗi với Node v24 bằng cách so sánh socket npm run build với npm run build. Xóa các dấu nháy đơn literal khỏi giá trị --node-options của tiến trình được khởi chạy, sau đó xác minh rằng giai đoạn kiểm tra TypeScript của Next.js hoàn tất mà không có ERR_MISSING_OPTION.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
next.js, node.js, typescript
Lĩnh vực
build-system, cli
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
78/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.