1

I have this npm command "create-new": "node --no-warnings --loader ts-node/esm tools/createNewCommand.ts" in tools directory. If I try to import from src/ I get this error: CustomError: Cannot find package '@/main.js'. Maybe the way im running the command is wrong, i dont understand transpiling modules very well, any help or advice is appreciated. thanks

Here are the config files: tsconfig.json

{
  "compilerOptions": {
    "target": "ESNext",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "typeRoots": ["@types", "./node_modules/@types"],
    "resolveJsonModule": true,
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"]
    },
    "allowJs": true,
    "outDir": "dist",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "skipLibCheck": true,
    "strictPropertyInitialization": false
  },
  "ts-node": {
    "swc": true
  },
  "include": ["src/**/*", "tools/**/*"]
}

.swcrc

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": false,
      "decorators": true,
      "dynamicImport": true
    },
    "target": "esnext",
    "paths": {
      "@routes/*": ["./src/routes/*"],
      "@middlewares/*": ["./src/middlewares/*"],
      "@/*": ["./src/*"]
    },
    "baseUrl": ".",
    "experimental": {
      "keepImportAssertions": true
    }
  },
  "module": {
    "type": "nodenext"
  }
}

0 Answers0