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.

Other potential Error source for "Error: Cannot find symbol for node: x"

See original GitHub issue

Hi,

first of all: thank for this great product.

tldr: Instead of using named imports use dynamic imports when hitting the “Cannot find symbol for node”-Error.

long version: I use it very intensive to create my definition files. I use it to create base packages, which get consumed by other packages, which get then get consumed by my projects.

When generating one of my base packages, which get consumed by another package, i got “Error: Cannot find symbol for node: amqplib”. I tried everything to figure out why it was erroring. installed everywhere @types/amqplib but could not solve the issue.

Then i set in tsconfig skipLibCheck to false and got a different error:

node_modules/project/amqp/types/index.d.ts(29,72): error TS2503: Cannot find namespace 'amqplib'.
node_modules/project/amqp/types/index.d.ts(49,20): error TS2304: Cannot find name 'Channel'.
node_modules/project/amqp/types/index.d.ts(69,53): error TS2503: Cannot find namespace 'amqplib'.
node_modules/project/amqp/types/index.d.ts(71,21): error TS2503: Cannot find namespace 'amqplib'.
node_modules/project/amqp/types/index.d.ts(77,46): error TS2503: Cannot find namespace 'amqplib'.
node_modules/project/amqp/types/index.d.ts(78,52): error TS2503: Cannot find namespace 'amqplib'.

Channel is an interface from amqplib.

I was importing it by doing

import { Channel } from amqplib;

And was referenced by Channel. So I changed the named import to a dynamic import.

import * as amqplib from amqplib;

And referenced it as amqplib.Channel.

And then dts-bundle-generator worked as expected.

Seems like dts-bundle-generator does not like named imports for types. Or maybe it fails in tsc. Not important where 😉.

I dont know if this was already explicitly documented, but I strongly recommend to document it. Took some time to figure it out by myself, and all the other search results were not hinting to this problem. So if somebody hits the same issue, he/she should first check for potential named imports and change them to dynamic imports.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
Uzlopakcommented, Nov 12, 2021

Hi timocov,

I have to admin: No. I learn from this issue, that I should encapsulate my plugins better, so that I wont need any external typings anymore.

I close this issue, as it was a result of bad practice anyway.

Thank you for your time! Thanks again for the great product!

0reactions
timocovcommented, Nov 12, 2021

@Uzlopak do you have any news?

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - What does a "Cannot find symbol" or "Cannot resolve ...
A "Cannot find symbol" error means that the compiler cannot do this. Your code appears to be referring to something that the compiler...
Read more >
How to Resolve The Cannot Find Symbol Error in Java - Rollbar
The cannot find symbol error refers to a situation where the Java compiler is unable to find the symbol associated with a given...
Read more >
Error: Cannot find symbol for node: JSX #161 - GitHub
Bug report Hi I am trying to generate the .d.ts file for a simple button react component when doing this i get a...
Read more >
What can cause the "cannot find symbol" error in Java?
The “cannot find symbol” error occurs mainly when we try to reference a variable that is not declared in the program which we...
Read more >
Understanding Java's Cannot Find Symbol Error Message
The "Cannot Find Symbol" error in a Java program might mean that there isn't enough information to execute 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