Trying to understand if I always need to identify commonjs or module?

I have the following package.json file and do not see a type key, but they are using es module import statement. They also import json files without using createRequire(). How is this possible? Add to that that they are using require statements as well...how? var os = require('os'); in index.js below
{
"name": "incoming-mobile-event-service",
"version": "1.0.15",
"description": "ES6 RESTful Express API for SOME SERVICE",
"main": "dist",
"scripts": {
},
"eslintConfig": {
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
},
"env": {
"node": true,
"es6": true
},
"rules": {
"no-console": 1,
"no-unused-vars": 1
}
},
"repository": "https://gitlab.com/COMPANYDev/COMPANY-DEPT/SOME-service",
"author": "COMPANY IT",
"dependencies": {
},
"devDependencies": {
}
}
{
"name": "incoming-mobile-event-service",
"version": "1.0.15",
"description": "ES6 RESTful Express API for SOME SERVICE",
"main": "dist",
"scripts": {
},
"eslintConfig": {
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
},
"env": {
"node": true,
"es6": true
},
"rules": {
"no-console": 1,
"no-unused-vars": 1
}
},
"repository": "https://gitlab.com/COMPANYDev/COMPANY-DEPT/SOME-service",
"author": "COMPANY IT",
"dependencies": {
},
"devDependencies": {
}
}
index.js
import bodyParser from 'body-parser';
import express from 'express';
import validator from 'express-validator';
import http from 'http';
import morgan from 'morgan';
import swagger from 'swagger-ui-express';

import config from './config.json';
import swaggerConfig from './config/swagger.json';
import winston from './config/winston';
import tracing from './config/tracing';
import {
defaultNotFoundHandler,
defaultErrorHandler,
} from './controllers/error.controller';
import { checkDatabaseConnections } from './config/health';

var os = require('os');
import bodyParser from 'body-parser';
import express from 'express';
import validator from 'express-validator';
import http from 'http';
import morgan from 'morgan';
import swagger from 'swagger-ui-express';

import config from './config.json';
import swaggerConfig from './config/swagger.json';
import winston from './config/winston';
import tracing from './config/tracing';
import {
defaultNotFoundHandler,
defaultErrorHandler,
} from './controllers/error.controller';
import { checkDatabaseConnections } from './config/health';

var os = require('os');
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server