Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning when try to import '@gitbeaker/rest' #3230

Closed
2 tasks
merorafael opened this issue Apr 29, 2023 · 15 comments
Closed
2 tasks

Warning when try to import '@gitbeaker/rest' #3230

merorafael opened this issue Apr 29, 2023 · 15 comments
Labels

Comments

@merorafael
Copy link
Contributor

Description

  • Node.js version: 19.9.0
  • Gitbeaker version: 38.0.1
  • Gitbeaker release (cli, node, browser, core, requester-utils): rest
  • OS & version: Arch Linux

The eslint shows the warning message below
"@gitbeaker/rest" is not found. eslint[node/no-missing-import](node/no-missing-import) when trying to import GitLab from @gitbeaker/rest.

Steps to reproduce

Import GitLab from @gitbeaker/rest using the structure below:

import {Gitlab} from '@gitbeaker/rest'

It is not relevant information, but the eslint settings use oclif and oclif-typescript rules.

Expected behaviour

No warnings when importing the @gitbeaker/rest

Actual behaviour

Warning node/no-missing-import on @gitbeaker/rest module.

Possible fixes

Checklist

  • I have checked that this is not a duplicate issue.
  • I have read the documentation.
@jdalrymple
Copy link
Owner

Odd. From the docs, it seems to say that the module itself does not exist? Do you receive the same errors with different imports ie Projects, Issues, etc? Is it just the Gitlab one?

@jdalrymple
Copy link
Owner

Following up, any more information?

@merorafael
Copy link
Contributor Author

merorafael commented May 5, 2023

It's only this library. Other libraries and project structures don't have this warning.

@jdalrymple
Copy link
Owner

Hmm, im not sure. Though i doubt it would change, have you tried updating the library version youre using, or perhaps refreshing your package-lock or yarn-lock file?

@tbazin
Copy link
Contributor

tbazin commented May 12, 2023

Hi! Just starting using this SDK and I am getting a very similar error:
Unable to resolve path to module '@gitbeaker/rest'.eslint (import/no-unresolved).

I suspect that the two error messages are occurrences of the same bug, only in @merorafael's case in the context of a node environment and in mine when using the package within a browser environment.

This is likely due to this open issue on eslint's side and the fact that the @gitbeaker/rest package relies on the exports field in its package.json :

"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
}
},

The error can be silenced by adding:

...
"type": "module",
...

to @gitbeaker/rest's package.json, but this field is not officially supported.

Alternate solutions suggested in the issue in eslint's repository include installing custom eslint resolvers that support the exports field in package.json files.

@jdalrymple
Copy link
Owner

Thanks for the additional info! Ill see if i can find some custom eslint resolvers that i could utilize

@merorafael
Copy link
Contributor Author

I put an example in a public repository here.
Here is the code: https://github.com/merorafael/gitbeaker-error-example/blob/main/src/commands/hello/index.ts

If you need to test, you must clone this repository and run yarn lint.

@jdalrymple
Copy link
Owner

Awesome thank you! This week is a rough one on my end, but i will get to it by at least the weekend!

@jdalrymple
Copy link
Owner

jdalrymple commented May 20, 2023

Okay few ways to resovle this:

  1. Ignore the rule for this library (similar example):
  "rules": {
    "node/no-missing-import": ["error", { "allowModules": ["@gitbeaker/rest"] }]
  }
  1. Use an additional resolver: https://www.npmjs.com/package/eslint-import-resolver-exports, though i didnt have much luck when testing this.

As @tbazin mentioned, this is because the eslint resolver just doesnt support export keyword as of yet.

@nawaz-malla
Copy link

File d/contract.py", line 4, in
app = Application("External Example App")

how can I solve the issue

@jdalrymple
Copy link
Owner

@nawaz-malla Can you provide more information. It looks like the code you included is python..

@nawaz-malla
Copy link

from beaker import *
from pyteal import Expr, abi

app = Application("External Example App")

@app.external
def add(a: abi.Uint8, b: abi.Uint8, *, output: abi.Uint8) -> Expr:
return output.set(a.get() + b.get())

@jdalrymple
Copy link
Owner

Again...thats python.

@nawaz-malla
Copy link

how can i solve , i am following some videos , they use beaker, I am using same code but I face the issue.
hoiw can I solve the issue.

algokit doctor
timestamp: 2024-03-27T00:18:17+00:00
AlgoKit: 1.13.1
AlgoKit Python: 3.12.1 (main, Dec 7 2023, 20:45:44) [Clang 15.0.0 (clang-1500.1.0.2.5)] (location: /Users/nawaz/Desktop/Algorand/Library/Application Support/pipx/venvs/algokit)
OS: macOS-14.4-x86_64-i386-64bit
docker: 25.0.2
docker compose: 2.24.3-desktop.1
git: 2.39.3
python: Command not found!
python3: 3.12.1 (location: /usr/local/bin/python3)
pipx: 1.4.3
poetry: 1.8.2
node: 21.6.2
npm: 10.2.4
brew: 4.2.15
there are details I am using

@jdalrymple
Copy link
Owner

@nawaz-malla Feel free to open a new issue with a template project to outline your problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants