TypeScript: Could not find a declaration file for module in unit tests, only - node.js

I'm using TypeScript with Visual Studio Code on Windows 10 to develop an NPM module. I use mocha/chai combined with nyc (istanbul) for unit testing and code coverage.
For some of my tests I would like to use chai-bytes to compare buffers more easily. Unfortunately, there is no type definition file in the chai-bytes module and there is no definition at #types/chai-bytes available.
Therefore, I have written my own type definition file for the chai-bytes plugin (which is very simple), but during execution of npm test I get the following error:
TSError: ⨯ Unable to compile TypeScript:
test/utls/BitArray-test.ts(3,23): error TS7016: Could not find a declaration file for module 'chai-bytes'. 'C:/Users/<user>/Source/Repos/velux-api/node_modules/chai-bytes/index.js' implicitly has an 'any' type.
Try `npm install #types/chai-bytes` if it exists or add a new declaration (.d.ts) file containing `declare module 'chai-bytes';`
test/utls/BitArray-test.ts(48,38): error TS2339: Property 'equalBytes' does not exist on type 'Assertion'.
VS Code provides me with full Intellisense, so I think my type definition file works and is found at least by VS Code.
This is my directory structure:
dist\ <-- My compiled code goes here
utils\
BitArray.d.ts
BitArray.js
BitArray.js.map
index.d.ts
index.js
index.js.map
...
src\
utils\
BitArray.ts
index.ts
...
test\
utils\
BitArray-test.ts
... (other test files)
mocha.opts
types\
chai-bytes\
index.d.ts <-- Type definition file for 'chai-bytes'
I have tried to move the type definition file to the source tree (several places), but with no effect, besides, that sometimes it got even worse, so that even VS Code haven't found it anymore.
These are my config files:
package.json:
{
"name": "klf-200-api",
"version": "3.0.0",
"description": "This module provides a wrapper to the socket API of a Velux KLF-200 interface. You will need at least firmware 0.2.0.0.71 on your KLF interface for this library to work.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": {
"name": "Michael Schroeder"
},
"dependencies": {
"#types/promise-timeout": "^1.3.0",
"promise-timeout": "^1.3.0"
},
"devDependencies": {
"#types/chai": "^4.1.6",
"#types/chai-as-promised": "^7.1.0",
"#types/mitm": "^1.3.2",
"#types/mocha": "^5.2.5",
"#types/node": "^10.11.7",
"#types/sinon": "^5.0.7",
"#types/sleep": "0.0.7",
"babel-eslint": "^8.0.0",
"chai": "^4.1.0",
"chai-as-promised": "^7.1.1",
"chai-bytes": "^0.1.1",
"chai-sinon": "^2.8.1",
"cross-env": "^5.2.0",
"eslint": "^4.7.1",
"eslint-config-defaults": "^9.0.0",
"eslint-plugin-react": "^7.3.0",
"gulp": "^4.0.0",
"gulp-release-it": "^2.0.14",
"gulp-typescript": "^5.0.0-alpha.3",
"gulp-uglify": "^3.0.1",
"istanbul": "^0.4.5",
"mitm": "^1.4.0",
"mocha": "^3.4.2",
"nock": "^9.0.14",
"nyc": "^13.1.0",
"sinon": "^7.1.1",
"sleep": "^5.2.3",
"source-map-support": "^0.5.9",
"ts-mocha": "^2.0.0",
"ts-node": "^7.0.1",
"typescript": "^3.1.2",
"uglify-es": "^3.3.9"
},
"scripts": {
"test": "cross-env TS_NODE_FILES=true nyc mocha",
"document": "jsdoc src -r -c ./.jsdoc.json -d docs"
},
"nyc": {
"include": [
"src/**/*.ts",
"src/**/*.tsx"
],
"extension": [
".ts",
".tsx"
],
"exclude": [
"**/*.d.ts"
],
"reporter": [
"text-summary",
"html"
],
"all": true
},
"repository": {
"type": "git",
"url": "https://github.com/MiSchroe/klf-200-api"
},
"keywords": [
"klf-200",
"IoT"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/MiSchroe/klf-200-api/issues"
},
"homepage": "https://mischroe.github.io/klf-200-api/"
}
tsconfig.json:
{
"compilerOptions": {
/* Basic Options */
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"declaration": true, /* Generates corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
"outDir": "./dist", /* Redirect output structure to the directory. */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
/* Module Resolution Options */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
},
"include": [
"./src/**/*"
]
}
mocha.opts:
--require ts-node/register
--require source-map-support/register
--recursive
--full-trace
--bail
test/**/*.ts
types\chai-bytes\index.d.ts:
/// <reference types="chai" />
declare module "chai-bytes" {
function chaiBytes(chai: any, utils: any): void;
export = chaiBytes;
}
declare namespace Chai {
// For BDD API
interface Assertion extends LanguageChains, NumericComparison, TypeComparison {
equalBytes(expected: string | Array<number> | ArrayLike<number>): void;
}
}
BitArray-test.ts (only the relevant test):
import { expect } from "chai";
import { bitArrayToArray, arrayToBitArray } from "../../src/utils/BitArray";
import chaibytes from "chai-bytes";
'use strict';
chai.use(chaibytes);
describe("...", function() {
it("should return an the correctly filled buffer", function() {
const nums: number[] = [0, 2, 4, 6, 8, 10, 12, 14];
const result = arrayToBitArray(nums, 2);
expect(result).to.be.an.instanceof(Buffer);
expect(result).to.be.equalBytes([0x55, 0x55]);
});
});
npm --version:
3.10.10
node --version:
v6.11.1
I could use Buffer.compare as work-around instead, but then I wouldn't see the buffers' content in the error message but only a -1, 0 or 1. (And it wouldn't solve the problem.)
Currently, I'm stuck at that point and any help is much appreciated.

At tsconfig.json add:
"typeRoots": [
"./node_modules/#types",
"./types"
] /* List of folders to include type definitions from. */
to the compilerOptions list.
Change the header of the BitArray-test.ts file:
import { bitArrayToArray, arrayToBitArray } from "../../src/utils/BitArray";
import chaibytes from "chai-bytes";
import { expect, use } from "chai";
'use strict';
use(chaibytes);

Related

[eslint][node.js] eslint-disable not working

I'm trying to disable eslint for a line of code but to no effect.
I tried to tackle the problem as in eslint docs. One approach, used in C:...somepath...\index.js:
/* eslint-disable */
const fetch = (url, init) =>
import('node-fetch').then(({ default: fetch }) => fetch(url, init));
/* eslint-enable */
And another approach, used in C:\Users...somepath...\shared\index.js:
// eslint-disable-next-line
const fetch = (url, init) => import('node-fetch').then(({ default: fetch }) => fetch(url, init));
None of them seem to work as while running npx eslint "**/*.js" I keep on getting:
C:\...somepath...\index.js
6:32 error Parsing error: Unexpected token import
C:\Users\...somepath...\shared\index.js
11:7 error Parsing error: Unexpected token import
I'm using commonjs, and yes, I know that import is not designed to be used out of es modules but according to node-fetch documentation I can do so and the solution is working fine. Yet, eslint is still throwing errors. After failing to add some rules ignoring importing, I decided to just disable the problematic pieces of code.
I'm extending airbnb and my .eslintrc is as simple as that:
{
"extends": "airbnb"
}
Relevant dependencies/devDependencies in package.json:
"dependencies": {
"node": "^16.17.0",
"node-fetch": "^3.2.10",
"npm": "^8.19.1"
},
"devDependencies": {
"#typescript-eslint/eslint-plugin": "^5.36.2",
"#typescript-eslint/parser": "^5.36.2",
"eslint": "^8.2.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"prettier": "2.7.1"
}
I've tried applying /* eslint-disable */ to a whole file to check whether it works at all - no it doesn't. This led me to think whether airbnb doesn't have sth like "noInlineConfig": true set but I checked and it seems like not the case.
Can you please help me with the issue?
In order to use dynamic imports in your code, you need to set the language version to 2020 or higher. The preferred way to do so is to set a predefined environment in your .eslintrc file:
{
"extends": "airbnb",
"env": {
"es2020": true
}
}
to set the language version for a particular file only, use an override:
{
"extends": "airbnb",
"overrides": [{
"files": "./path/to/file.js",
"env": {
"es2020": true
}
}]
}

While deploying a NodeJs app to heroku, I started getting tsc compilation error even though tsc works fine in my machine

I have been using heroku for a while now and I did not have any error until I created a new entity model and controller. After committing these changes I tried to deploy to heroku. I got this error message.
...
-----> Installing dependencies
Installing node modules (yarn.lock)
yarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
$ tsc
src/user/order/controller.ts(10,21): error TS2307: Cannot find module '../../db/Order' or its corresponding type declarations.
src/user/order/controller.ts(12,27): error TS2307: Cannot find module '../../db/entity/Order' or its corresponding type declarations.
src/user/order/controller.ts(110,49): error TS7006: Parameter 'e' implicitly has an 'any' type.
src/user/order/controller.ts(139,61): error TS7031: Binding element 'recipeId' implicitly has an 'any' type.
src/user/order/controller.ts(139,71): error TS7031: Binding element 'quantity' implicitly has an 'any' type.
src/user/order/controller.ts(164,13): error TS2322: Type '[unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown]' is not assignable to type '{ recipe: { coffeeName: string; usedBrandIngredients: { brandIngredient: string; amount: number; }[]; }; quantity: number; }[]'.
Type '{}' is missing the following properties from type '{ recipe: { coffeeName: string; usedBrandIngredients: { brandIngredient: string; amount: number; }[]; }; quantity: number; }': recipe, quantity
src/user/order/model.ts(2,27): error TS2307: Cannot find module '../../db/entity/Order' or its corresponding type declarations.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
-----> Build failed
...
After this log, I checked my code again and did not find any error. Then, I tried to run tsc command locally. It worked fine and generated the dist file. I could not find any reason why tsc gives error on heroku.
These are the scripts and dependencies at package.json
"scripts": {
"postinstall": "tsc",
"develop": "nodemon src/services/api.ts",
"start": "node dist/services/api.js"
},
"dependencies": {
"bcrypt": "^5.0.1",
"cors": "^2.8.5",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"express-validator": "^6.12.1",
"helmet": "^4.6.0",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.12.14",
"nodemailer": "^6.7.4"
},
"devDependencies": {
"#types/bcrypt": "^5.0.0",
"#types/cors": "^2.8.12",
"#types/dotenv": "^8.2.0",
"#types/express": "^4.17.13",
"#types/express-validator": "^3.0.0",
"#types/jsonwebtoken": "^8.5.5",
"#types/mongoose": "^5.11.97",
"#types/node": "^16.7.12",
"#types/nodemailer": "^6.4.4",
"nodemon": "^2.0.12",
"ts-node": "^10.2.1",
"typescript": "^4.4.2"
}
Here is the content of the tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"noImplicitAny": true,
"moduleResolution": "node",
"sourceMap": true,
"resolveJsonModule": true,
"outDir": "dist",
"baseUrl": ".",
"paths": {
"*": [
"node_modules/*"
]
}
},
"include": [
"src/**/*"
],
"ts-node": {
"files": true
}
}
Any idea would be helpful.
EDIT: It seems that the import line was causing problem. I changed import {Order} from "../../db/Order"; to import {Order} from "../../db/order"; and it did not give error. It was working fine on local with ts-node and tsc, but was not working with the tsc at heroku.
It seems that the import line was causing problem. I changed import {Order} from "../../db/Order"; to import {Order} from "../../db/order"; and it did not give error. It was working fine on local with ts-node and tsc, but was not working with the tsc at heroku.

How to import d3.js in a node and typescript project? [ERR_REQUIRE_ESM]

I'm working on a node project using typescript, oclif and d3.js, among other things. Typescript was configured by npx when creating the project with oclif so I didn't control all aspects of it (especially regarding TS, and I'm not an expert. TS is great, but configuration wise, meh).
Anyway, everything was working fine, but I recently added d3 as a dependency and tried to build a document, and I get this error when running it:
(node:22554) [ERR_REQUIRE_ESM] Error Plugin: dbacl [ERR_REQUIRE_ESM]: require() of ES Module /dbacl/node_modules/d3/src/index.js from /dbacl/src/tree/graph-tree.ts not supported.
Instead change the require of index.js in /Users/nico/Furo/Dev/dbacl/src/tree/graph-tree.ts to a dynamic import() which is available in all CommonJS modules.
In the file where I'm using d3 I import it as per documentation:
import * as d3 from 'd3'
I suspect it might be a problem after compiling, so here is tsconfig.json. I didn't change anything since generation by npx.
{
"compilerOptions": {
"declaration": true,
"importHelpers": true,
"module": "commonjs",
"outDir": "dist",
"rootDir": "src",
"strict": true,
"target": "es2019",
},
"include": [
"src/**/*"
]
}
And in case it's more relevant, here is my package.json file as well (didn't change anything either):
{
"name": "dbacl",
"version": "0.0.0",
"description": "",
"author": "",
"bin": {
"dbacl": "./bin/run"
},
"license": "MIT",
"main": "dist/index.js",
"repository": "*****/dbacl",
"files": [
"/bin",
"/dist",
"/npm-shrinkwrap.json",
"/oclif.manifest.json"
],
"dependencies": {
"#oclif/core": "^1",
"#oclif/plugin-help": "^5",
"#oclif/plugin-plugins": "^2.0.1",
"#types/d3": "^7.4.0",
"#types/jsdom": "^16.2.14",
"d3": "^7.6.1",
"directory-tree": "^3.3.0",
"jsdom": "^20.0.0",
"lodash": "^4.17.21"
},
"devDependencies": {
"#oclif/test": "^2",
"#types/chai": "^4",
"#types/mocha": "^9.0.0",
"#types/node": "^16.9.4",
"chai": "^4",
"eslint": "^7.32.0",
"eslint-config-oclif": "^4",
"eslint-config-oclif-typescript": "^1.0.2",
"globby": "^11",
"mocha": "^9",
"oclif": "^3",
"shx": "^0.3.3",
"ts-node": "^10.2.1",
"tslib": "^2.3.1",
"typescript": "^4.4.3"
},
"oclif": {
"bin": "dbacl",
"dirname": "dbacl",
"commands": "./dist/commands",
"plugins": [
"#oclif/plugin-help",
"#oclif/plugin-plugins"
],
"topicSeparator": " ",
"topics": {
"hello": {
"description": "Say hello to the world and others"
}
}
},
"scripts": {
"build": "shx rm -rf dist && tsc -b",
"lint": "eslint . --ext .ts --config .eslintrc",
"postpack": "shx rm -f oclif.manifest.json",
"posttest": "yarn lint",
"prepack": "yarn build && oclif manifest && oclif readme",
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
"version": "oclif readme && git add README.md"
},
"engines": {
"node": ">=12.0.0"
},
"keywords": [
"oclif"
],
"types": "dist/index.d.ts"
}
I find this problem quite confusing because everywhere I've been searching about this problem, it seems I'm doing the right thing. I assume the problem might be between my screen and my chair, but really I don't get it. Also, should I use the dynamic import like this?
const d3 = await import('d3')
I tried, it didn't work. I made the function that generates the document async and added that line at the start but nope. Anyway, if I believe the error, that would be the way to go but I didn't see this solution anywhere when looking for a solution to my problem. What do you guys think?
Thanks
So thanks to the input from a colleague and this article, the problem is that d3 now supports ESM only. So when the compiler turns the import into
// index.ts
import * as d3 from 'd3'
// compiled index.js
const d3 = require('d3')
it just doesn't work. I was using d3 version 7, and a quick fix to it was to downgrade to version 6.7.0, when it did support commonJS.
Now, I have to move on with this project, but I'll keep looking into it and into how I can use a recent version of d3 in my project. If I do, I'll edit that answer!
Cheers

Import HTML as string and test with Jest

I'm using sveltekit and I can't use the files api to import html templates. So I decided to import by writing a module that imports the content of the document as a string (described here).
// src/global.d.ts
/// <reference types="#sveltejs/kit" />
declare module '*.html' {
const content: string
export default content
}
So far so good, but now I need to test the code and jest can't interpret the code.
● Test suite failed to run
Jest encountered an unexpected token
Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.
Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.
By default "node_modules" folder is ignored by transformers.
Here's what you can do:
• If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
• If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/configuration
For information about custom transformations, see:
https://jestjs.io/docs/code-transformation
Details:
/home/developer/workspace/src/assets/html/confirm_email.html:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){<!DOCTYPE html>
^
SyntaxError: Unexpected token '<'
I don't understand how jest understands the .d.ts files... How do I get to test the code?
Do you install #babel/plugin-transform-runtime"?
I share my config for jest/svelte-jester..
I have:
jsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"$lib": ["src/lib"],
"$lib/*": ["src/lib/*"]
}
},
"include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"],
}
svelte.config.js
import vercel from '#sveltejs/adapter-vercel'
/** #type {import('#sveltejs/kit').Config} */
const config = {
kit: {
adapter: vercel(),
vite: {
define: {
'process.env': process.env,
},
},
},
transform: {
"^.+\\.svelte$": ["svelte-jester", { "preprocess": true }]
}
};
export default config;
babel.config.json
{
"presets": [
["#babel/preset-env", { "modules": "auto" }]
],
"plugins": ["babel-plugin-transform-vite-meta-env","#babel/plugin-transform-runtime"]
}
jest.config.js
export default {
"transform": {
"^.+\\.js$": "babel-jest",
"^.+\\.svelte$": "svelte-jester",
},
"moduleFileExtensions": ["svelte", "js"],
"testEnvironment": "jsdom",
"setupFilesAfterEnv": ["#testing-library/jest-dom/extend-expect"]
}
and whole package.json
{
"name": "sveltekit",
"version": "0.0.1",
"scripts": {
"dev": "svelte-kit dev",
"build": "svelte-kit build",
"package": "svelte-kit package",
"preview": "svelte-kit preview",
"test": "jest src",
"test:watch": "npm run test -- --watch"
},
"devDependencies": {
"#babel/core": "^7.16.12",
"#babel/plugin-transform-modules-commonjs": "^7.16.8",
"#babel/plugin-transform-runtime": "^7.17.0",
"#babel/preset-env": "^7.16.11",
"#supabase/supabase-js": "^1.29.1",
"#sveltejs/adapter-auto": "^1.0.0-next.7",
"#sveltejs/kit": "^1.0.0-next.215",
"#sveltejs/svelte-virtual-list": "^3.0.1",
"#testing-library/svelte": "^3.0.3",
"autoprefixer": "^10.4.1",
"babel-jest": "^27.4.6",
"babel-plugin-transform-vite-meta-env": "^1.0.3",
"jest": "^27.4.7",
"postcss-load-config": "^3.1.1",
"prettier": "^2.5.1",
"prettier-plugin-svelte": "^2.5.1",
"svelte": "^3.44.0",
"svelte-jester": "^2.1.5",
"svelte-lazy": "^1.0.12",
"tailwindcss": "^3.0.8",
"ts-jest": "^27.1.3"
},
"type": "module",
"dependencies": {
"#fontsource/fira-mono": "^4.5.0",
"#lukeed/uuid": "^2.0.0",
"#testing-library/jest-dom": "^5.16.1",
"cookie": "^0.4.1",
"svelte-lazy-image": "^0.2.0",
"swiper": "^8.0.3"
},
"testEnvironment": "jsdom"
}
I hope it will help you.I had a lot of troubles too with setting up jest..
1.Import html as string
I solved the problem using another approach...
I'm using a resource of vite to import the html file as an asset, as can be seen here in the documentation
import confirm_email_template from '../../../assets/html/confirm_email.html?raw'
2.Test using Jest
For production it works perfectly, but for unit testing the code breaks because Jest can't import the asset as a module.
So the second part of the problem was fixed (I don't know if this is the best practice) using asset mocks.
// jest.config.cjs
{
⋮
moduleNameMapper: {
⋮
'([a-zA-Z_ ]+\\.html)\\?raw$': '<rootDir>/__mocks/$1.cjs'
}
⋮
}
To make it work, I created the following folder structure:
__mocks
|
confirm_email.html.cjs
another_asset_mocked.html.cjs
The confirm_email.html.cjs looks like this:
// __mocks/confirm_email.html.cjs
module.exports = '<html>content<html>'

TSC won't compile on different systems

I created a node app in typescript. When I run tsc locally everything works and I can run the app. But when I deploy on heroku, it is giving me compilation errors :
app/api/controllers/ingredient.controller.ts(3,24): error TS2307: Cannot find module '../schemas/ingredient.schema'.
app/api/controllers/ingredient.controller.ts(23,13): error TS7006: Parameter 'units' implicitly has an 'any' type.
app/api/controllers/ingredient.controller.ts(30,42): error TS7006: Parameter 'result' implicitly has an 'any' type.
app/api/controllers/ingredient.controller.ts(37,70): error TS7006: Parameter 'result' implicitly has an 'any' type.
app/api/controllers/ingredient.controller.ts(44,70): error TS7006: Parameter 'result' implicitly has an 'any' type.
The strange thing is that I made sure all versions are the same: NPM, Node, TSC ...
I have a TSConfig that is picked up and used. Where else am I supposed to look ?
Versions:
> node -v && npm -v && tsc -v && tsc
v13.3.0
6.13.1
Version 3.7.3
Package.json:
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "build/app.js",
"scripts": {
"tsc": "node -v && npm -v && tsc -v && tsc",
"watch-ts": "tsc -w",
"watch-node": "nodemon build/app.js",
"watch": "docker-compose up -d && concurrently -k -p \"[{name}]\" -n \"TypeScript, Node\" -c \"yello.bold, cyan.bold\" \"yarn run watch-ts\" \"yarn run watch-node\"",
"start": "node build/app.js",
"build": "npm run tsc"
},
"author": "",
"license": "ISC",
"dependencies": {
"#overnightjs/core": "^1.6.9",
"#overnightjs/logger": "^1.1.9",
"#types/body-parser": "^1.17.1",
"#types/cors": "^2.8.6",
"#types/dotenv": "^8.2.0",
"#types/express": "^4.17.2",
"#types/mongodb": "^3.3.11",
"#types/mongoose": "^5.5.32",
"#types/multer": "^1.3.10",
"concurrently": "^5.0.0",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"mongoose": "^5.7.13",
"multer": "^1.4.2",
"nodemon": "^2.0.1",
"typescript": "^3.7.3"
},
"engines": {
"node": "13.3.0",
"npm": "6.13.1"
}
}
TSCONFIG:
{
"compilerOptions": {
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"outDir": "build", /* Redirect output structure to the directory. */
"rootDir": "./app", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"importHelpers": true, /* Import emit helpers from 'tslib'. */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
/* Module Resolution Options */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
"baseUrl": "./", /* Base directory to resolve non-absolute module names. */
"typeRoots": [ /* List of folders to include type definitions from. */
"node_modules/#types"
],
"types": ["node"], /* Type declaration files to be included in compilation. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
/* Experimental Options */
"experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
"emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
},
"include": [
"app/*"
]
}
Advice
Run tsc locally and deploy the built .js files.
Don't deploy typescript files, that's going to add a lot of code to your remote code base.
The Error
this errors means some ts rules are not getting applied to your local ts.
I noticed rootDir is ./app and you have include as /app. Maybe it's looking for an /app folder under /app. Try ./ as root and see if that fixes it. Btw, I'm the creator of OvernightJS and I highly recommend you transpile all code before deploying.

Resources