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

Error when importing nanoid function in pet model. "nanoid is not a function" #27

Open
RaminMammadzada opened this issue Apr 3, 2021 · 1 comment

Comments

@RaminMammadzada
Copy link

RaminMammadzada commented Apr 3, 2021

Issue:

It gives the following error when importing nanoid method inside pet.js file.

 "errors": [
    {
      "message": "nanoid is not a function",

The exact location of import:

const nanoid = require('nanoid')

@RaminMammadzada RaminMammadzada changed the title The error when importing nanoid function in pet model. "nanoid is not a function" Error when importing nanoid function in pet model. "nanoid is not a function" Apr 3, 2021
@RaminMammadzada
Copy link
Author

RaminMammadzada commented Apr 3, 2021

Solution:

The nanoid function must be imported as named import as it is given in the documentation:

const { nanoid } = require('nanoid')

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

No branches or pull requests

1 participant