question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

request CommonJS version

See original GitHub issue

I have typescript project with article-parser, but after update got crashed because this lib using ESM. Please compile the CommonJS version.

gambar

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
dimaslanjakacommented, Sep 2, 2022

Node 16.x latest Typescript 4.x latest

0reactions
dimaslanjakacommented, Sep 17, 2022

iam tried ur snippet with my project configuration (iam using ts-node to run it btw)

Using 7.0.1

image

Using 7.0.2 image image

Using 7.0.3 (work) image image

tsconfig.json

{
  // Change this to match your project
  "include": [
    "*.ts",
    "./views",
    "./public",
    "./src",
    "./chimeraland",
    "./chimeraland/typings",
    "./tlon"
  ],
  "compilerOptions": {
    "module": "CommonJS",
    "target": "es2018",
    // Tells TypeScript to read JS files, as
    // normally they are ignored as source files
    "allowJs": true,
    "checkJs": false,
    // Generate d.ts files
    "declaration": true,
    // This compiler run should
    // only output d.ts files
    "emitDeclarationOnly": false,
    // Types should go into this directory.
    // Removing this would place the .d.ts files
    // next to the .js files
    "outDir": "dist",
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "moduleResolution": "node",
    "allowSyntheticDefaultImports": true,
    "skipLibCheck": true,
    "skipDefaultLibCheck": true,
    "noImplicitAny": false,
    "noUnusedLocals": false,
    "allowUmdGlobalAccess": true,
    "allowUnreachableCode": true,
    "allowUnusedLabels": true,
    "noImplicitThis": false,
    "typeRoots": [
      "./node_modules/@types",
      "./tmp/typings",
      "./src/types"
    ],
    "types": [
      "datatables.net",
      "jquery",
      "node",
      "toastr",
      "bootstrap"
    ],
    "lib": [
      "DOM",
      "ES5",
      "ES6",
      "ES2015",
      "ES2016",
      "ES2017",
      "ES2018",
      "ES2019",
      "ES2020",
      "DOM.Iterable",
      "WebWorker"
    ]
  },
  "typeAcquisition": {
    "enable": true
  },
  "exclude": [
    "**/node_modules/**"
  ]
}

package.json

{
  "name": "hexo-backend",
  "version": "0.3.0",
  "description": "A sample Node.js app using Express 4",
  "engines": {
    "node": "16.x"
  },
  "main": "index.js",
  "scripts": {
    "start": "node dist/index.js",
    "dev": "cross-env-shell NODE_ENV=development node -r ts-node/register index.dev.ts",
    "prod": "cross-env-shell NODE_ENV=production node -r ts-node/register index.dev.ts",
    "fix": "git config config.pull false && git config core.autocrlf false",
    "update": "npx npm-check-updates -u -x chalk",
    "test": "node test.js",
    "push": "npm-run-all -s push:**",
    "push:build-pre": "npm run install:remote",
    "push:build": "gulp tsc copy commit",
    "push:github": "git push github hexo-backend",
    "push:heroku": "git push heroku hexo-backend:master",
    "install:local": "npm i file:../git-command-helper file:../persistent-cache --save",
    "install:remote": "npm i https://github.com/dimaslanjaka/git-command-helper https://github.com/dimaslanjaka/persistent-cache#improve2 --save",
    "gallery-deploy": "npm-run-all -s gallery gallery-push",
    "gallery": "node -r ts-node/register chimeraland/gallery/index.ts",
    "gallery-push": "node -r ts-node/register chimeraland/gallery/_deploy.test.ts",
    "heroku:pull": "git pull heroku master --recurse-submodules"
  },
  "dependencies": {
    "@algolia/autocomplete-js": "^1.7.1",
    "ansi-colors": "^4.1.3",
    "article-parser": "^7.0.3",
    "axios": "^0.27.2",
    "basic-ftp": "^5.0.2",
    "bluebird": "^3.7.2",
    "bootstrap": "^5.2.1",
    "chalk": "^1.0.0",
    "clean-css": "^5.3.1",
    "cors": "^2.8.5",
    "countries-list": "^2.6.1",
    "datatables.net": "^1.12.1",
    "debug": "^4.3.4",
    "deepmerge-ts": "^4.2.1",
    "dotenv": "^16.0.2",
    "ejs": "^3.1.8",
    "event-stream": "~4.0.1",
    "express": "^4.18.1",
    "express-session": "^1.17.3",
    "folder-hash": "^4.0.2",
    "fs-extra": "^10.1.0",
    "ftp": "^0.3.10",
    "git-command-helper": "github:dimaslanjaka/git-command-helper",
    "gulp-util": "^3.0.8",
    "hexo-util": "^2.7.0",
    "html-minifier": "^4.0.0",
    "html-minifier-terser": "^7.0.0",
    "image-validator": "^1.2.1",
    "install": "^0.13.0",
    "javascript-obfuscator": "^4.0.0",
    "jquery": "^3.6.1",
    "js-cookie": "^3.0.1",
    "jsdom": "^20.0.0",
    "kill-process-by-name": "file:packages/kill-process-by-name",
    "moment-timezone": "^0.5.37",
    "node-libcurl": "^2.3.4",
    "node-sass": "^7.0.3",
    "node-tesseract-ocr": "^2.2.1",
    "npm": "^8.19.2",
    "persistent-cache": "github:dimaslanjaka/persistent-cache#improve2",
    "select2": "^4.1.0-rc.0",
    "session-file-store": "^1.5.0",
    "sharp": "^0.31.0",
    "shell-exec": "^1.1.2",
    "ssh2-sftp-client": "^9.0.4",
    "terser": "^5.15.0",
    "through2": "^4.0.2",
    "tiny-lr": "2.0.0",
    "toastr": "^2.1.4",
    "upath": "^2.0.1"
  },
  "devDependencies": {
    "@types/bluebird": "^3.5.36",
    "@types/bootstrap": "^5.2.4",
    "@types/cors": "^2.8.12",
    "@types/ejs": "^3.1.1",
    "@types/express": "^4.17.14",
    "@types/express-session": "^1.17.5",
    "@types/folder-hash": "^4.0.2",
    "@types/fs-extra": "^9.0.13",
    "@types/ftp": "^0.3.33",
    "@types/gulp": "^4.0.9",
    "@types/gulp-util": "^3.0.36",
    "@types/hexo-util": "^0.6.5",
    "@types/html-minifier": "^4.0.2",
    "@types/html-minifier-terser": "^7.0.0",
    "@types/jquery": "^3.5.14",
    "@types/js-cookie": "^3.0.2",
    "@types/jsdom": "^20.0.0",
    "@types/moment-timezone": "^0.5.30",
    "@types/node": "^18.7.18",
    "@types/node-sass": "^4.11.3",
    "@types/prettier": "^2.7.0",
    "@types/select2": "^4.0.55",
    "@types/session-file-store": "^1.2.2",
    "@types/sharp": "^0.31.0",
    "@types/ssh2-sftp-client": "^7.1.0",
    "@types/through2": "github:dimaslanjaka/nodejs-package-types#through2",
    "@types/toastr": "^2.1.40",
    "@typescript-eslint/eslint-plugin": "^5.37.0",
    "@typescript-eslint/parser": "^5.37.0",
    "cross-env": "^7.0.3",
    "eslint": "^8.23.1",
    "eslint-config-prettier": "^8.5.0",
    "eslint-plugin-prettier": "^4.2.1",
    "got": "^12.4.1",
    "gulp": "^4.0.2",
    "nodemon": "^2.0.20",
    "npm-run-all": "^4.1.5",
    "prettier": "^2.7.1",
    "safelinkify": "file:../safelink",
    "tape": "^5.6.0",
    "ts-node": "^10.9.1",
    "typescript": "^4.8.3"
  },
  "repository": {
    "type": "git",
    "url": "https://git.heroku.com/hexo-backend"
  },
  "homepage": "https://hexo-backend.herokuapp.com/",
  "keywords": [
    "node",
    "heroku",
    "express"
  ],
  "license": "MIT"
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

CommonJS modules | Node.js v19.3.0 Documentation
CommonJS modules are the original way to package JavaScript code for Node.js. Node.js also supports the ECMAScript modules standard used by browsers and ......
Read more >
CommonJS vs. ES modules in Node.js - LogRocket Blog
Learn about the differences between CommonJS and ES modules when using them in Node.js applications to organize software code.
Read more >
How the module system, CommonJS & require works
Learn how the Node.js module system & CommonJS works and what does ... You can find out what version of npm you are...
Read more >
common-js - npm
Latest version: 0.3.8, last published: 6 years ago. Start using common-js in your project by running `npm i common-js`.
Read more >
Documentation - ECMAScript Modules in Node.js - TypeScript
In a CommonJS module, this just boils down to a require() call, and in an ES module, this imports ... CJS fall-back for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found