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.

Import error on typescript environment

See original GitHub issue

I’m use:

  • node v14.5.0,
  • typescript v3.9.6
  • ts-node v8.10.2

on a Windows 10 system, and when I only import Minisearch like:

import Minisearch from 'minisearch';

I get the follow error on try run with ts-node:

const searcher = new Minisearch({
                 ^
TypeError: minisearch_1.default is not a constructor
    at Object.<anonymous> (C:\Users\farin\atla\bercario\bot\src\internals\Searcher.ts:8:18)
    at Module._compile (internal/modules/cjs/loader.js:1201:30)
    at Module.m._compile (C:\Users\farin\atla\bercario\bot\node_modules\ts-node\src\index.ts:858:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
    at Object.require.extensions.<computed> [as .ts] (C:\Users\farin\atla\bercario\bot\node_modules\ts-node\src\index.ts:861:12)       
    at Module.load (internal/modules/cjs/loader.js:1050:32)
    at Function.Module._load (internal/modules/cjs/loader.js:938:14)
    at Module.require (internal/modules/cjs/loader.js:1090:19)
    at require (internal/modules/cjs/helpers.js:75:18)

Can anyone help me? I’m not know if I’m doing something wrong and I can’t imagine how to fix that.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
slawikocommented, Jun 7, 2021

Hello folks,

I just encountered the same issue when I tried to test (using Jest) angular service that operates with MiniSearch library. I was able to fix the issue by substituting my tsconfig.spec.json with

"compilerOptions": {
      "module": "esnext",
      "esModuleInterop": true
  }
1reaction
danielbomcommented, Jul 9, 2020

I remove the node_modules and try install again, and works. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import refers to. Consider an import statement like import {...
Read more >
Typescript: Cannot use import statement outside a module
The error means Node found an import statement in a file that it does not consider an ECMAScript (ES) module. Adding "type": "module"...
Read more >
TypeScript errors and how to fix them
This error occurs when you import the same file in two different files using two different casing styles (ex. camelCase and UpperCamelCase):.
Read more >
File is not a module error in TypeScript | bobbyhadz
The error "File is not a module" simply means that the file does not contain any export or import statements. Any file that...
Read more >
False errors in Typescript files, import statements are not ...
While working with Typescript I import dependencies from other files. Resharper grays them out as not used and then further in the code...
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