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

Import errors in universal-cookie and react-cookie #440

Closed
pinarruiz opened this issue Jan 3, 2024 · 3 comments · Fixed by #441
Closed

Import errors in universal-cookie and react-cookie #440

pinarruiz opened this issue Jan 3, 2024 · 3 comments · Fixed by #441

Comments

@pinarruiz
Copy link

When doing the following import:

import Cookies from 'universal-cookie';

I get the following error:

Type error: Could not find a declaration file for module 'universal-cookie'. '/home/user/project/node_modules/.pnpm/[email protected]/node_modules/universal-cookie/esm/index.mjs' implicitly has an 'any' type.
  There are types at '/home/user/project/node_modules/universal-cookie/esm/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'universal-cookie' library may need to update its package.json or typings.

>  8 | import Cookies from 'universal-cookie';
     |                     ^

Something similar happens with react-cookie:
Doing the next import:

import { useCookies } from "react-cookie";

Gives the next error:

Type error: Could not find a declaration file for module 'react-cookie'. '/home/user/project/node_modules/.pnpm/[email protected][email protected]/node_modules/react-cookie/esm/index.mjs' implicitly has an 'any' type.
  There are types at '/home/user/project/node_modules/react-cookie/esm/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'react-cookie' library may need to update its package.json or typings.

  1 | import React from "react";
  2 | import { useRouter } from "next/router";
> 3 | import { useCookies } from "react-cookie";
    |                            ^

This only happened when i tried to update any of them to 7.0.0.

Using pnpm version 8.14.0 as package manager and Nextjs 14.0.4 as framework.

package.json dependencies:

{
  "dependencies": {
    "@hookform/resolvers": "3.3.3",
    "@mantine/hooks": "7.4.0",
    "@radix-ui/react-dialog": "1.0.5",
    "@radix-ui/react-dropdown-menu": "2.0.6",
    "@radix-ui/react-label": "2.0.2",
    "@radix-ui/react-select": "2.0.0",
    "@radix-ui/react-separator": "1.0.3",
    "@radix-ui/react-slot": "1.0.2",
    "@radix-ui/react-switch": "1.0.3",
    "@radix-ui/react-tabs": "1.0.4",
    "@radix-ui/react-toast": "1.1.5",
    "@radix-ui/react-tooltip": "1.0.7",
    "@tanstack/react-query": "5.17.0",
    "class-variance-authority": "0.7.0",
    "clsx": "2.1.0",
    "lucide-react": "0.303.0",
    "next": "14.0.4",
    "next-themes": "0.2.1",
    "react": "18.2.0",
    "react-cookie": "6.1.3",
    "react-dom": "18.2.0",
    "react-hook-form": "7.49.2",
    "tailwind-merge": "2.2.0",
    "tailwindcss-animate": "1.0.7",
    "universal-cookie": "7.0.0",
    "zod": "3.22.4"
  },
  "devDependencies": {
    "@tanstack/eslint-plugin-query": "5.14.6",
    "@tanstack/react-query-devtools": "5.17.0",
    "@types/node": "20.10.6",
    "@types/react": "18.2.46",
    "@types/react-dom": "18.2.18",
    "autoprefixer": "10.4.16",
    "eslint": "8.56.0",
    "eslint-config-next": "14.0.4",
    "eslint-config-prettier": "9.1.0",
    "husky": "8.0.3",
    "lint-staged": "15.2.0",
    "npm-run-all": "4.1.5",
    "postcss": "8.4.32",
    "prettier": "3.1.1",
    "shadcn-ui": "0.6.0",
    "tailwindcss": "3.4.0",
    "typescript": "5.3.3",
    "vercel": "33.0.1"
  },
}
@thib3113
Copy link
Contributor

thib3113 commented Jan 3, 2024

the error seems to came from the package.json exports ... I will try to do a PR

@eXon
Copy link
Collaborator

eXon commented Jan 6, 2024

This is fixed in v7.0.1

@ihr-it-projekt
Copy link

ihr-it-projekt commented Jan 8, 2024

THX a lot, it work now also for us. :-)

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

Successfully merging a pull request may close this issue.

4 participants