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

swc + yarn #882

Open
vorandrew opened this issue Dec 1, 2024 · 1 comment
Open

swc + yarn #882

vorandrew opened this issue Dec 1, 2024 · 1 comment

Comments

@vorandrew
Copy link

vorandrew commented Dec 1, 2024

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"
}

@psychobolt
Copy link

psychobolt commented Dec 27, 2024

See here: #807 . Yarn is not supported after > 1.10.1. You will have to downgrade.

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