jest.config.js fails - unexpected token '.' in module.exports - javascript

I must be missing something but I'm struggling to understand this error.
How can . be unexpected in module.exports={}?
Please point me in the right direction. Thanks!
\jest.config.js:16
module.exports = {
^
SyntaxError: Unexpected token '.'
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at readConfigFileAndSetRootDir (...\node_modules\jest-config\build\readConfigFileAndSetRootDir.js:119:22)
at readConfig (...\node_modules\jest-config\build\index.js:217:65)
at readConfigs (...\node_modules\jest-config\build\index.js:406:32)
npm ERR! Test failed. See above for more details.
jest.config.js:
module.exports = {
transform: {
"^.+\\.[jt]sx?$": "<rootDir>/jest-preprocess.js",
},
moduleNameMapper: {
".+\\.(css|styl|less|sass|scss)$": `identity-obj-proxy`,
".+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": `<rootDir>/__mocks__/file-mock.js`,
},
testPathIgnorePatterns: [`node_modules`, `\\.cache`, `<rootDir>.*/public`],
transformIgnorePatterns: [`node_modules/(?!(gatsby)/)`],
globals: {
__PATH_PREFIX__: ``,
},
testURL: `http://localhost`,
setupFiles: [`<rootDir>/loadershim.js`],
module.exports = {
setupFilesAfterEnv: ["<rootDir>/setup-test-env.js"],
}
};

You have an extra module.exports embedded in the object at the bottom. looks like the file should be:
module.exports = {
transform: {
"^.+\\.[jt]sx?$": "<rootDir>/jest-preprocess.js",
},
moduleNameMapper: {
".+\\.(css|styl|less|sass|scss)$": `identity-obj-proxy`,
".+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": `<rootDir>/__mocks__/file-mock.js`,
},
testPathIgnorePatterns: [`node_modules`, `\\.cache`, `<rootDir>.*/public`],
transformIgnorePatterns: [`node_modules/(?!(gatsby)/)`],
globals: {
__PATH_PREFIX__: ``,
},
testURL: `http://localhost`,
setupFiles: [`<rootDir>/loadershim.js`],
setupFilesAfterEnv: ["<rootDir>/setup-test-env.js"],
};

Related

unable to call a local module from an application file in node.js

I am beginner in node.js.
I am trying to call a very basic addition module saved in C:\wks\guru99 with file name: Node_03_addition.js. The calling application is also saved in the same location with the name: app.js
Addition Module:
var exports = module.exports = {};
exports.addNumber=function(a,b)
{
return a+b;
};
Application File:
var Addition = require('/.Node_03_addition.js');
console.log(Addition.addNumber(1,2));
when I run the application in cmd using node app.js
I am receiving the error that Module is not found. Can someone please help me with where I am going wrong here.
c:\wks\guru99>node app.js
internal/modules/cjs/loader.js:969
throw err;
^
Error: Cannot find module '/.Node_03_addition.js'
Require stack:
- c:\wks\guru99\app.js
[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:842:27)[39m
[90m at Module.require (internal/modules/cjs/loader.js:1026:19)[39m
[90m at require (internal/modules/cjs/helpers.js:72:18)[39m
at Object.<anonymous> (c:\wks\guru99\app.js:1:16)
[90m at Module._compile (internal/modules/cjs/loader.js:1138:30)[39m
[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)[39m
[90m at Module.load (internal/modules/cjs/loader.js:986:32)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:879:14)[39m
[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)[39m {
code: [32m'MODULE_NOT_FOUND'[39m,
requireStack: [ [32m'c:\\wks\\guru99\\app.js'[39m ]
}
SUGGESTION
// Node_03_addition.js
// Declare your function
const addNumber = function(a,b) {
return a + b;
};
// Export your function
module.exports = {
addNumber
};
// Application-File.js
// Import your module
const Addition = require('./Node_03_addition');
// Use it
console.log(Addition.addNumber(1,2)); // 3
Addition Module:
var exports = module.exports = {};
exports.addNumber=function(a,b)
{
return a+b;
};
Application File:
var Addition = require('./Node_03_addition.js');
console.log(Addition.addNumber(1,2));

mocha testing Angular (typescript) app that uses OpenLayers 6 fails with 'turf mocha "syntaxError: Unexpected token {"'

I solved this during the writing of the question and have provided my answer below since it was a bit tricky to work out. I am happy to hear any better or alternative answers.
I have an Angular OpenLayers 6 geomapping app. Being Angular I use Typescript and it transpiles and runs fine. And also being Angular it uses ng test to do the testing. All tests run fine.
However I use mocha + chai for testing in the IDE (IntelliJ) since I don't require UI testing for the mathematical work I'm currently performing (ng test runs the UI tests if and when I need that. But in the IDE I select the tests to run). Testing this way worked fine until I added a new test that creates a new instance of a class that imports GeoJSON:
import GeoJSON from 'ol/format/GeoJSON';
That test fails (in mocha) with:
/home/smx9b6/dev/ng-eow/node_modules/ol/format/GeoJSON.js:17
import { assert } from '../asserts.js';
^
SyntaxError: Unexpected token {
Looking at the GeoJSON.js file it seems to have UMD module format (i think this is UMD):
/**
* #module ol/format/GeoJSON
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { assert } from '../asserts.js';
import Feature from '../Feature.js';
var GeoJSON = /** #class */ (function (_super) {
__extends(GeoJSON, _super);
/**
* #param {Options=} opt_options Options.
*/
function GeoJSON(opt_options) {
...
}
GeoJSON.prototype.writeGeometryObject = function (geometry, opt_options) {
return writeGeometry(geometry, this.adaptOptions(opt_options));
};
return GeoJSON;
}(JSONFeature));
And others, such as turf.js use the ES6 module format. eg. line-to-polygon:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var bbox_1 = require("#turf/bbox");
var invariant_1 = require("#turf/invariant");
var helpers_1 = require("#turf/helpers");
...
function lineToPolygon(lines, options) {
if (options === void 0) { options = {}; }
...
}
...
exports.default = lineToPolygon;
Mocha can't deal with this but Angular can - I don't know why. I run mocha with (as reported by IntelliJ when running the test - full paths removed):
node node_modules/mocha/bin/_mocha --require ts-node/register --ui bdd --reporter mochaIntellijReporter.js
src/app/geometry-ops.spec.ts --grep "^geometry-ops centroid "
I have commonjs set as the module type:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": [],
"resolveJsonModule": true,
"module": "commonjs",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
},
...
}
The error in full is:
/home/smx9b6/dev/ng-eow/node_modules/ol/format/GeoJSON.js:17
import { assert } from '../asserts.js';
^
SyntaxError: Unexpected token {
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/home/smx9b6/dev/ng-eow/src/app/layers-geometries.ts:4:1)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Module.m._compile (/home/smx9b6/dev/ng-eow/node_modules/ts-node/src/index.ts:439:23)
at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Object.require.extensions.(anonymous function) [as .ts] (/home/smx9b6/dev/ng-eow/node_modules/ts-node/src/index.ts:442:12)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/home/smx9b6/dev/ng-eow/src/app/geometry-ops.spec.ts:13:1)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Module.m._compile (/home/smx9b6/dev/ng-eow/node_modules/ts-node/src/index.ts:439:23)
at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Object.require.extensions.(anonymous function) [as .ts] (/home/smx9b6/dev/ng-eow/node_modules/ts-node/src/index.ts:442:12)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at /home/smx9b6/dev/ng-eow/node_modules/mocha/lib/mocha.js:334:36
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/home/smx9b6/dev/ng-eow/node_modules/mocha/lib/mocha.js:331:14)
at Mocha.run (/home/smx9b6/dev/ng-eow/node_modules/mocha/lib/mocha.js:809:10)
at Object.exports.singleRun (/home/smx9b6/dev/ng-eow/node_modules/mocha/lib/cli/run-helpers.js:108:16)
at exports.runMocha (/home/smx9b6/dev/ng-eow/node_modules/mocha/lib/cli/run-helpers.js:142:13)
at Object.exports.handler.argv [as handler] (/home/smx9b6/dev/ng-eow/node_modules/mocha/lib/cli/run.js:292:3)
at Object.runCommand (/home/smx9b6/dev/ng-eow/node_modules/mocha/node_modules/yargs/lib/command.js:242:26)
at Object.parseArgs [as _parseArgs] (/home/smx9b6/dev/ng-eow/node_modules/mocha/node_modules/yargs/yargs.js:1087:28)
at Object.parse (/home/smx9b6/dev/ng-eow/node_modules/mocha/node_modules/yargs/yargs.js:566:25)
at Object.exports.main (/home/smx9b6/dev/ng-eow/node_modules/mocha/lib/cli/cli.js:68:6)
at Object.<anonymous> (/home/smx9b6/dev/ng-eow/node_modules/mocha/bin/_mocha:10:23)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
I worked out and provide an answer below. However I would still like to hear any feedback on this. Such as should OpenLayers change their module format? (I'm still getting my head around all the different module formats).
The answer is to add --require esm --require jsdom-global/register to the node / mocha call.
The esm is to specify ES6 as the module format and jsdom-global is to define the DOM in non-browser environments (specifically to define document).
The full command is:
node node_modules/mocha/bin/_mocha --ui bdd \
--require ts-node/register \
--require esm \
--require jsdom-global/register \
--reporter landing \
src/app/geometry-ops.spec.ts --grep "^geometry-ops centroid "
(I added spaces in the command since it irks me when I have to scroll right to see such things).
I am happy to hear any better or alternative answers.

next.js + Webpack + CSS => SyntaxError: Unexpected token . (dot) = How to fix?

I am new to webpack and next.js. I get the following error, that seems webpack does not understand/parse/load CSS files correctly.
C:\devtmp\workspaces\nextjs\web-admin\node_modules\#patternfly\react-styles\css\components\Backdrop\backdrop.css:4
.pf-c-backdrop {
^
SyntaxError: Unexpected token .
How can I fix this or debug this further? As I am new, I am completely lost. What could be the cause for this problem?
Further Details:
1.) Full Stacktrace:
[ info ] bundled successfully, waiting for typecheck results ...
[ event ] build page: /test
[ wait ] compiling ...
[ info ] bundled successfully, waiting for typecheck results ...
[ ready ] compiled successfully - ready on http://localhost:3000
C:\devtmp\workspaces\nextjs\web-admin\node_modules\#patternfly\react-styles\css\components\Backdrop\backdrop.css:4
.pf-c-backdrop {
^
SyntaxError: Unexpected token .
at Module._compile (internal/modules/cjs/loader.js:720:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:683:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object.<anonymous> (C:\devtmp\workspaces\nextjs\web-admin\node_modules\#patternfly\react-styles\css\components\Backdrop\backdrop.js:3:1)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:683:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object.<anonymous> (C:\devtmp\workspaces\nextjs\web-admin\node_modules\#patternfly\react-core\dist\js\components\AboutModal\AboutModal.js:16:40)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
2.) The File that does the CSS import
file:///C:/devtmp/workspaces/nextjs/web-admin/node_modules/#patternfly/react-styles/css/components/Backdrop/backdrop.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("./backdrop.css");
exports.default = {
backdrop: 'pf-c-backdrop',
backdropOpen: 'pf-c-backdrop__open',
modifiers: {}
};
3.) The CSS
file:///C:/devtmp/workspaces/nextjs/web-admin/node_modules/#patternfly/react-styles/css/components/Backdrop/backdrop.css
/* stylelint-enable */
/* stylelint-disable */
/* stylelint-enable */
.pf-c-backdrop {
--pf-c-backdrop--ZIndex: var(--pf-global--ZIndex--lg);
--pf-c-backdrop--Color: var(--pf-global--BackgroundColor--dark-transparent-100);
--pf-c-backdrop--BackdropFilter: blur(10px);
position: fixed;
top: 0;
left: 0;
z-index: var(--pf-c-backdrop--ZIndex);
width: 100%;
height: 100%;
background-color: var(--pf-c-backdrop--Color);
/* stylelint-disable-next-line */
-webkit-backdrop-filter: var(--pf-c-backdrop--BackdropFilter);
backdrop-filter: var(--pf-c-backdrop--BackdropFilter); }
.pf-c-backdrop__open {
overflow: hidden; }
4.) Extract of next.config.js
module.exports = {
webpack: (config, options) => {
config.module.rules.push({
test: /\.css$/,
//exclude: ['/node_modules/'],
include: [
path.resolve(__dirname, 'pages'),
path.resolve(__dirname, 'node_modules/patternfly'),
path.resolve(__dirname, 'node_modules/#patternfly/patternfly'),
path.resolve(__dirname, 'node_modules/#patternfly/react-styles/css'),
path.resolve(__dirname, 'node_modules/#patternfly/react-core/dist/styles/base.css'),
path.resolve(__dirname, 'node_modules/#patternfly/react-core/dist/esm/#patternfly/patternfly'),
path.resolve(__dirname, 'node_modules/#patternfly/react-core/node_modules/#patternfly/react-styles/css'),
path.resolve(__dirname, 'node_modules/#patternfly/react-table/node_modules/#patternfly/react-styles/css'),
path.resolve(__dirname, 'node_modules/#patternfly/react-inline-edit-extension/node_modules/#patternfly/react-styles/css')
],
use: ["style-loader", "css-loader"]
});
...
Thanks very much!
As of the fact that next provide a solution for ssr & client side it has 2 webpack configs, one for each.
Instead of configuring it by yourself it is better to use the official (for now) plugin #zeit/next-css.
// next.config.js
const withCSS = require('#zeit/next-css')
module.exports = withCSS()
WARN Edit: 06-07-2021
This package has been deprecated
Author message:
Next.js now has built-in support for CSS: https://nextjs.org/docs/basic-features/built-in-css-support. The built-in support solves many bugs and painpoints that the next-css plugin had.

Troubles with using gulp-eslint

Im trying to add gulp-eslint to my build process, having gulp watch my files and run eslint whenever a file is changed. However, I am getting an error that says:
D:\code\project\node_modules\gulp-eslint\index.js:4
const {CLIEngine} = require('eslint');
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:413:25)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (D:\code\project\gulpfile.js:5:16)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
when I try to run the ESLint task that I wrote.
Here is the code for the eslint task:
gulp.task('eslint', () => {
return gulp.src(lintscripts)
.pipe(eslint({
"env": {
"browser": true,
"node": true,
"commonjs": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2017
},
"rules": {
'no-console': 'off',
'indent' : 'off',
"semi": [
"error",
"always"
]
}
})).pipe(eslint.format());
});
Please check your node version. You are using object destructuring which is available from Node v6. If you're using node v4 then this might not work.

How to import or require a TS-module into CommonJS file?

For whatever reason, some of my modules have to be js files.
I import ts module into my js file like this:
resolver.js:
import { Message } from '../../connectors/message';
// console.log('Message: ', Message);
const resolver = {
Query: {
sendMessage: (root, args, ctx) => {
console.log(args, ctx);
return Message.send('1', 'message');
}
}
};
export { resolver };
message.ts:
const Message = {
send(id, type) {
return Promise.resolve({
recipient_id: '123',
message_id: '122'
});
}
};
export { Message };
I use webpack to and awesome-typescript-loader to compile my .ts files.
Here is my tsconfig.json:
{
"compilerOptions": {
"target": "es6",
"lib": ["es6", "esnext"],
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": false,
"outDir": "dist",
"typeRoots": ["node_modules/#types"]
},
"files": ["src/main.ts"],
"exclude": ["node_modules"]
}
webpack.config.js:
var nodeExternals = require('webpack-node-externals');
var webpack = require('webpack');
var path = require('path');
var fs = require('fs');
/* helper function to get into build directory */
var distPath = function(name) {
if (undefined === name) {
return path.join('dist');
}
return path.join('dist', name);
};
var webpack_opts = {
entry: './src/main.ts',
target: 'node',
output: {
filename: distPath('main.js'),
libraryTarget: 'commonjs2'
},
resolve: {
extensions: ['.ts', '.js'],
modules: ['node_modules', 'src']
},
plugins: [
new webpack.LoaderOptionsPlugin({
options: {
test: /\.ts$/,
ts: {
compiler: 'typescript',
configFileName: 'tsconfig.json'
},
tslint: {
emitErrors: true,
failOnHint: true
}
}
})
],
devtool: 'source-map',
module: {
loaders: [
{
test: /\.ts$/,
loaders: 'awesome-typescript-loader'
}
]
},
externals: [nodeExternals()]
};
module.exports = webpack_opts;
But I got this error:
(function (exports, require, module, __filename, __dirname) { import { Message } from '../../connectors/message';
^^^^^^
SyntaxError: Unexpected token import
at new Script (vm.js:51:7)
at createScript (vm.js:136:10)
at Object.runInThisContext (vm.js:197:10)
at Module._compile (internal/modules/cjs/loader.js:618:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Module.require (internal/modules/cjs/loader.js:598:17)
at require (internal/modules/cjs/helpers.js:11:18)
How to solve this?
-- update v1 --
I try to use it with require
// import { Message } from '../../connectors/message';
const { Message } = require('../../connectors/message');
console.log('Message: ', Message);
const resolver = {
Query: {
sendMessage: (root, args, ctx) => {
console.log(args, ctx);
return Message.send('1', 'message');
}
}
};
export { resolver };
But I still got an error:
internal/modules/cjs/loader.js:550
throw err;
^
Error: Cannot find module '../../connectors/message'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
at Function.Module._load (internal/modules/cjs/loader.js:475:25)
at Module.require (internal/modules/cjs/loader.js:598:17)
at require (internal/modules/cjs/helpers.js:11:18)
at Object.<anonymous> (/Users/ldu020/workspace/workplace-adapter-graphql/src/graphql/modules/messages/resolver.js:3:21)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
-- update v2 --
I add .ts file extension to path:
const { Message } = require('../../connectors/message.ts');
still got error:
export { Message };
^^^^^^
SyntaxError: Unexpected token export
at new Script (vm.js:51:7)
at createScript (vm.js:136:10)
at Object.runInThisContext (vm.js:197:10)
at Module._compile (internal/modules/cjs/loader.js:618:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Module.require (internal/modules/cjs/loader.js:598:17)
at require (internal/modules/cjs/helpers.js:11:18)
update 3: add package.json
"devDependencies": {
"#types/faker": "^4.1.4",
"#types/jest": "^19.2.4",
"#types/node": "^7.10.0",
"babel-cli": "^6.26.0",
"faker": "^4.1.0",
"jest": "^20.0.4",
"ts-jest": "^20.0.6",
"ts-node": "^3.2.0",
"tslint": "^5.11.0",
"typescript": "^2.9.2"
},
your node version doesn't support import. use require instead:
var Message = require('./path').Message;
-- update --
since you are trying to import a .ts file, you need to write that in the path. like this: require('./path.ts');
try using require('../../connectors/message')

Categories