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.

Using own package name in import statement causes missing dependency error

See original GitHub issue

Bug Description

Let’s assume I have a package my-awesome-package with the following structure:

|-package.json
|+foo
  |+bar
    |-index.js
|-constants.js

So, in my index.js I’d like to use some constants, but for some reason instead of doing

import { PI } from "../../constants";

I prefer to use

import { PI } from "my-awesome-package/constants";

So when I run depcheck it throws a missing dependency error

Versions

  • node -v: v8.11.4
  • npm -v: 5.6.0
  • depcheck -v: 0.6.1

Extra info

I’m not quite sure about how cool using import statements containing own package name is, but it looks ok for me

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
phil-lgrcommented, Jun 17, 2022

With Node 16 self reference are supported https://nodejs.org/api/packages.html#self-referencing-a-package-using-its-name, I’m wondering how to handle this with depcheck now

0reactions
matz3commented, Sep 27, 2022

I fully agree with @phil-lgr. This should not cause a missing dependency issue in case the package defines “exports” in the package.json.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Intellij Cannot resolve symbol on import - java - Stack Overflow
There can be multiple reasons for this. In my case it was wrong source root issue. Invalidate caches didn't work along with other...
Read more >
report-missing-dependencies - NPM Package Overview - Socket
Reports an error if a package (e.g. import {xx} from "my-package" ) is used in the src folder but not defined in the...
Read more >
Missing Dependencies after Importing Object Manager ...
Select “Proceed” and name the Undo package when prompted. ... Users encounter error regarding missing dependency. CAUSE:
Read more >
Running mypy and managing imports
When mypy encounters an import statement or receives module names from the command line via the --module or --package flags, mypy tries to...
Read more >
eslint-plugin-import - npm
This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import ...
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