swc-project / swc-project/swc-node

swc + yarn

Open
#882 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2k
Forks
95
Avg merge
14d 11h
Merged PRs (30d)
1

Description

What's happening?

 yarn node --import @swc-node/register/esm-register -r dotenv/config -- src/m.ts

node:internal/modules/run_main:122
    triggerUncaughtException(
    ^
Error: Cannot find module 'express': express cannot be resolved in file:///Users/vorandrew/prj/tg/src/m.ts
    at resolve (file:///Users/vorandrew/prj/tg/.yarn/__virtual__/@swc-node-register-virtual-5997e970a3/4/.yarn/berry/cache/@swc-node-register-npm-1.10.9-055388e573-10c0.zip/node_modules/@swc-node/register/esm/esm.mjs:157:15)
    at async nextResolve (node:internal/modules/esm/hooks:748:22)
    at async Hooks.resolve (node:internal/modules/esm/hooks:240:24)
    at async handleMessage (node:internal/modules/esm/worker:199:18)

Node.js v23.1.0

tsconfig.json

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "_version": "23.0.0",
  "compilerOptions": {
    "lib": ["es2023"],
    "module": "NodeNext",
    "target": "ESNext",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "moduleResolution": "NodeNext"
  }
}

package.json

{
  "name": "bot",
  "description": "bot",
  "version": "1.0.0",
  "private": true,
  "main": "index.js",
  "type": "module",
  "scripts": {
    "dev": "yarn node --watch --import @swc-node/register/esm-register -r dotenv/config -- src/dev.ts",
    "build": "swc src -s --out-dir dist",
    "start": "node dist/src/index.js"
  },
  "engines": {
    "node": ">=18.0.0"
  },
  "dependencies": {
    "express": "^4.21.1",
    "knex": "^3.1.0",
    "pg": "^8.13.1"
  },
  "devDependencies": {
    "@eslint/js": "^9.13.0",
    "@swc-node/register": "^1.10.9",
    "@swc/cli": "^0.4.1-nightly.20240914",
    "@swc/core": "^1.7.40",
    "@swc/jest": "^0.2.36",
    "@tsconfig/node23": "^23.0.0",
    "@types/bluebird": "^3.5.42",
    "@types/eslint__js": "^8.42.3",
    "@types/express": "^5.0.0",
    "@types/jest": "^29.5.14",
    "@types/node": "22.7.9",
    "@typescript-eslint/eslint-plugin": "^8.11.0",
    "@typescript-eslint/parser": "^8.11.0",
    "dotenv": "^16.4.5",
    "eslint": "^9.13.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-prettier": "^5.2.1",
    "globals": "^15.11.0",
    "jest": "^29.7.0",
    "nodemon": "^3.1.7",
    "prettier": "3.3.3",
    "prettier-eslint": "^16.3.0",
    "typescript": "^5.6.3",
    "typescript-eslint": "^8.11.0"
  },
  "packageManager": "yarn@4.5.3"
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names tsconfig.json, package.json, and src/m.ts; start by running the shown command with Node.js 23.1.0 and Yarn 4.5.3. Compare the reported Express resolution with the provided configuration and determine the reproducible behavior and expected resolution outcome.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.