Code Monkey home page Code Monkey logo

Comments (6)

radzserg avatar radzserg commented on August 21, 2024 1

"type": "module" should do the trick. @jdiaz-wcslat @pedro-lima-reis can you also share your package.json file. Thank you.

from rsdi3.

radzserg avatar radzserg commented on August 21, 2024

@pedro-lima-reis what version of node do you use and can you share your package.json file please

from rsdi3.

jdiaz-wcslat avatar jdiaz-wcslat commented on August 21, 2024

@radzserg i have the same problem

nodejs v20.4.0

"devDependencies": { "@commitlint/cli": "^17.7.1", "@commitlint/config-conventional": "^17.7.0", "@types/config": "^3.3.0", "@types/dotenv": "^8.2.0", "@types/express": "^4.17.20", "@types/lodash": "^4.14.195", "@types/node": "^20.4.2", "@typescript-eslint/eslint-plugin": "^6.7.0", "@typescript-eslint/parser": "^6.7.0", "ts-node-dev": "^2.0.0", "tsx": "^3.12.7", "typescript": "^4.9.5" }, "dependencies": { "@typegoose/typegoose": "^11.3.0", "body-parser": "^1.20.1", "config": "^3.3.9", "dotenv": "^16.3.1", "express": "^4.18.2", "rsdi": "^3.0.3", "zod": "^3.21.4" }

from rsdi3.

pedro-lima-reis avatar pedro-lima-reis commented on August 21, 2024

v18.17.1

from rsdi3.

paulo123araujo avatar paulo123araujo commented on August 21, 2024

@pedro-lima-reis did you try to bundle your application to esm and not to commonjs?

A time ago i faced this same kinda of problem, and i solve changing the way my application was built.

just to exemplify, I use these configs:

// tsup.config.ts
import { defineConfig } from 'tsup';

export default defineConfig({
  tsconfig: './tsconfig.json',
  entry: ['./src/**/*.ts'],
  splitting: true,
  sourcemap: true,
  clean: true,
  platform: 'node',
  esbuildOptions(options, _context) {
    // the directory structure will be the same as the source
    options.outbase = './src';
  },
  target: 'node20',
  format: 'esm',
  treeshake: true,
  outDir: 'build',
});
// tsconfig.json
{
    "compilerOptions": {
        "types": ["node"],
        "module": "ESNext",
        "moduleResolution": "Node",
        "target": "ES2020",
        "baseUrl": ".",
        "outDir": "build",
        "esModuleInterop": true,
        "strict": true,
        "resolveJsonModule": true,
        "skipLibCheck": true,
        "sourceMap": true,
        "forceConsistentCasingInFileNames": true,
        "allowJs": true,
        "rootDirs": ["src"],
        "lib": ["DOM", "ESNext"],
        "removeComments": true,
        "paths": {
            "@tests/*": ["./tests/*"],
            "@/*": ["./src/*"]
        },
        "typeRoots": ["./types"],
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "strictPropertyInitialization": false
    },
    "include": ["src", "tests"],
    "exclude": ["node_modules"]
}

and in package.json I set "type": "module", and with all this settings the application worked on production.

Hope it helps.

from rsdi3.

radzserg avatar radzserg commented on August 21, 2024

I'm closing this issue for now, since we don't have much feedback.

from rsdi3.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.