error TS2497: Module ''jimp'' resolves to a non-module entity and cannot be imported using this construct.
See original GitHub issueHi,
I cannot import jimp with typescript, getting error. Details are below.
Expected Behavior
There shouldn’t be a compilation-time error.
Current Behavior
There is a compilation-time error.
error TS2497: Module ''jimp'' resolves to a non-module entity and cannot be imported using this construct. import * as jimp from 'jimp';
Also, import jimp from 'jimp';
doesn’t work because it imports the jimp into jimp_1 and becomes not usable…
Failure Information (for bugs)
Steps to Reproduce
Import jimp in a typescript file with import * as jimp from 'jimp';
- Jimp Version: ^0.3.9
- Operating System: MacOS
- Node version: v8.11.3
- TypeScript version: 3.0.1
Failure Logs
error TS2497: Module ''jimp'' resolves to a non-module entity and cannot be imported using this construct. import * as jimp from 'jimp';
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:22 (6 by maintainers)
Top Results From Across the Web
What does "... resolves to a non-module entity and cannot be ...
Module "MyClass" resolves to a non-module entity and cannot be imported using this construct. and when trying to call fn(). Cannot invoke an ......
Read more >error TS2497: Module ''jimp'' resolves to a non-module entity and ...
Hi,. I cannot import jimp with typescript, getting error. Details are below. Expected Behavior. There shouldn't be a compilation-time error.
Read more >Typescript – What does “… resolves to a non-module entity ...
This gives me errors when trying to use new. Module "MyClass" resolves to a non-module entity and cannot be imported using this construct....
Read more >importing non-module python files (intermediate) anthony ...
today I show how to import non- modules in python -- either with invalid module names or files which aren't .py at all!playlist: ......
Read more >Definitely Typed
Once you've tested your definitions with real code, make a PR then follow the ... error TS2497: Module 'foo' resolves to a non-module...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ll add the ignore and create the PR but I’ll keep this issue open (will rewrite the commit message to remove the “resolves” part). I think the ideal case would be to rewrite the declarations file, specifically by extracting the
class Jimp
from thenamespace Jimp
and basically restructuring it entirely.Actually yes, I have since figured out that it works with
import Jimp = require('jimp');
. It ended up being documented on typescriptlangExtract:
IMO it feels off to be using
require
in TypeScript but if we would like to useimport * as Jimp from 'jimp'
or such a more ES6 Import/Export structure the definitions file would have to be rewritten a lot I’m afraid. I tried messing around myself a lot but I couldn’t get it that’s for sure :\