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.

Typescript import doesn't work.

See original GitHub issue

When importing Analytics using Typescript: import Analytics from 'analytics-node';

I get the following error:

node_modules/@types/analytics-node/index"' has no default export.

I can revert to this const Analytics = require('analytics-node');, but I should be able to do this with Typescript imports right?

As you can see above, I do have the type definitions installed as well.

Issue Analytics

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

github_iconTop GitHub Comments

8reactions
f2prateekcommented, Nov 4, 2017

I’m not that familiar with typescript, but looking at https://github.com/Microsoft/TypeScript/issues/3337#issuecomment-107971371; did you try this?

import * as analytics from 'analytics-node';
5reactions
lev-kuznetsovcommented, Nov 7, 2017

Looking at https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/analytics-node/index.d.ts I think you’re supposed to import like this:

import {Analytics} from 'analytics-node'
Read more comments on GitHub >

github_iconTop Results From Across the Web

Import statement does not work in typescript - Stack Overflow
Then I'm trying to import a class in a file using 'import' keyword. But despite having read about the declaration of modules in...
Read more >
Common TypeScript module problems and how to solve them
Solution 2: Locate the module and resolve imports ; 'view/file2' with the first location in the array ( ; "*" ), and combine...
Read more >
Imports not working in TypeScript project. · Issue #199 - GitHub
When I am trying to import any of the Props into a TypeScript project, import sizes from "open-props/src/sizes" I get a ts(2307) Error:...
Read more >
Documentation - Module Resolution - TypeScript
If you are having resolution problems with import s and export s in TypeScript, try setting moduleResolution: "node" to see if it fixes...
Read more >
Import Statements in TypeScript: Which Syntax to Use
This doesn't work when the module doesn't export an object with properties. Some modules export a function or a class instead.
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