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

Failed to resolve entry for package "remix-utils". #278

Closed
cjoecker opened this issue Nov 21, 2023 · 4 comments
Closed

Failed to resolve entry for package "remix-utils". #278

cjoecker opened this issue Nov 21, 2023 · 4 comments

Comments

@cjoecker
Copy link
Contributor

cjoecker commented Nov 21, 2023

Describe the bug

When I mock remix-ultils with vitest as vi.mock("remix-utils"), I get the error
Error: Failed to resolve entry for package "remix-utils". The package may have incorrect main/module/exports specified in its package.json: Missing "." specifier

Your Example Website or App

codesandbox.io/p/devbox/validated-form-error-forked-kd6m28?file=%2Fsrc%2FApp.test.tsx%3A10%2C1

Steps to Reproduce the Bug or Issue

Open codesandbox and see the terminal errors while running tests.

Expected behavior

There is no error on mocking remix-utils

Screenshots or Videos

No response

Platform

  • remix-utils v. 7.1.0

Additional context

No response

@sergiodxa
Copy link
Owner

There’s nothing at remix-utils, each util is a different module. You can see how to import each util individually in the README.

@kevinreber
Copy link

kevinreber commented Nov 22, 2023

Recently upgraded to Remix v2 and am having an issue where VSCode isn't picking up any of the remix-utils modules when using the same import path shown in the Honeypot README examples
CleanShot 2023-11-21 at 20 04 48

Everything works fine when using relative import paths
CleanShot 2023-11-21 at 20 15 40

still getting the same issue after making the changes suggested in this thread: #228 (comment)

My file setup below
remix.config.js

/** @type {import('@remix-run/dev').AppConfig} */
import { config } from "@netlify/remix-adapter";

export default {
  serverModuleFormat: "esm",
  ...config,
  ignoredRouteFiles: ["**/.*"],
  serverPlatform: "node",
  server:
    process.env.NETLIFY || process.env.NETLIFY_LOCAL
      ? "./server.ts"
      : undefined,
  serverBuildPath: ".netlify/functions-internal/server.js",
  postcss: false,
  tailwind: true,
  serverDependenciesToBundle: [
    "@radix-ui/themes",
    /^rc-util.*/,
  ],
};

tsconfig.json

{
  "include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
  "compilerOptions": {
    "lib": ["DOM", "DOM.Iterable", "ES2019"],
    "isolatedModules": true,
    "esModuleInterop": true,
    "jsx": "react-jsx",
    "module": "ES2022",
    "moduleResolution": "Bundler",
    "resolveJsonModule": true,
    "target": "ES2019",
    "strict": true,
    "allowJs": true,
    "forceConsistentCasingInFileNames": true,
    "baseUrl": ".",
    "paths": {
      "~/*": ["./app/*"]
    },
    "noEmit": true
  }
}

package.json

{
  "private": true,
  "sideEffects": false,
  "type": "module",
  "scripts": {
    "build": "remix build",
    "dev": "yarn run check-env-file && remix dev --manual",
    "start": "netlify dev",
    "typecheck": "tsc",
    "check-env-file": "node ./scripts/check-env-file.mjs",
    "postinstall": "prisma generate",
    "stripe:listen": "stripe listen --forward-to localhost:3000/webhook",
    "format": "prettier --write .",
    "lint": "eslint --cache --cache-location ./node_modules/.cache/eslint ."
  },
  "dependencies": {
    "@aws-sdk/client-s3": "^3.363.0",
    "@conform-to/react": "^0.9.1",
    "@conform-to/zod": "^0.9.1",
    "@heroicons/react": "^2.0.18",
    "@netlify/functions": "^2.3.0",
    "@netlify/remix-adapter": "^2.2.0",
    "@prisma/client": "^4.13.0",
    "@radix-ui/colors": "^3.0.0",
    "@radix-ui/react-label": "^2.0.2",
    "@radix-ui/react-select": "^2.0.0",
    "@radix-ui/react-switch": "^1.0.3",
    "@radix-ui/themes": "^2.0.1",
    "@remix-run/css-bundle": "^2.2.0",
    "@remix-run/express": "^2.2.0",
    "@remix-run/node": "2.2.0",
    "@remix-run/react": "2.2.0",
    "class-variance-authority": "^0.7.0",
    "clsx": "^2.0.0",
    "cross-env": "^7.0.3",
    "dotenv": "^16.0.3",
    "isbot": "^3.6.8",
    "openai": "^3.2.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "remix-auth": "^3.6.0",
    "remix-auth-socials": "^2.0.5",
    "remix-utils": "^7.1.0",
    "stripe": "^12.3.0",
    "tailwind-merge": "^2.0.0",
    "zod": "^3.22.4"
  },
  "devDependencies": {
    "@remix-run/dev": "2.2.0",
    "@remix-run/eslint-config": "2.2.0",
    "@remix-run/serve": "2.2.0",
    "@types/eslint": "^8.44.3",
    "@types/react": "^18.0.35",
    "@types/react-dom": "^18.0.11",
    "eslint": "^8.38.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-config-prettier": "^9.0.0",
    "prettier": "^3.0.3",
    "prisma": "^4.13.0",
    "tailwindcss": "^3.3.3",
    "typescript": "^5.3.0",
    "zx": "7.0.8"
  },
  "engines": {
    "node": "20.5.0"
  }
}

@cjoecker
Copy link
Contributor Author

@sergiodxa you are right, I forgot to update the paths in the mocks.
I think what @kevinreber means is another kind of issue, so I will close this issue for now.

@kevinreber
Copy link

By some miracle my issue just disappeared, didn't do anything special 😅
Feel free to ignore my comments 🙏 ⬆️ ⬆️

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

3 participants