简体   繁体   中英

Deployment on Vercel with Auth0: Can't resolve '@auth0/nextjs-auth0' in '/vercel/path0/pages'

I have a project that already was deployed on Vercel. Since last week Im working on improve the layout with the goal of finish a MVP of this project. So, I changed my usage of auth0, using the package to nextjs @auth0/nextjs-auth0 . I ran

npm install @auth0/nextjs-auth0

and I have on my package.json

{
  "name": "MAmanager",
  "version": "1.0.0",
  "engines": {
    "node": "14.x",
    "npm": "6.x"
  },
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "next",
    "start": "next start",
    "build": "next build"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@auth0/nextjs-auth0": "github:auth0/nextjs-auth0",
    "dayjs": "^1.9.5",
    "formik": "^2.1.5",
    "next": "^10.2.3",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-icons": "^4.2.0",
    "swr": "^0.5.6",
    "yup": "^0.29.3"
  },
  "devDependencies": {
    "autoprefixer": "^10.2.5",
    "postcss": "^8.3.0",
    "tailwindcss": "^2.1.2"
  }
}

The usages on my pages are

import { UserProvider } from '@auth0/nextjs-auth0'
import { useUser } from '@auth0/nextjs-auth0'
import { withPageAuthRequired } from '@auth0/nextjs-auth0'

And when I deploy my branch on Vercel I get this error

08:57:49.989    Failed to compile.
08:57:49.990    ModuleNotFoundError: Module not found: Error: Can't resolve '@auth0/nextjs-auth0' in '/vercel/path0/pages'
08:57:49.990    > Build error occurred
08:57:49.991    Error: > Build failed because of webpack errors
08:57:49.991        at /vercel/path0/node_modules/next/dist/build/index.js:17:924
08:57:49.991        at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:6:584)
08:57:50.020    error Command failed with exit code 1.

I have seen errors like that caused by casing discrepancies but I don't understanding what is happening here. I appreciate any help.

After see other examples I just edited manually the package.json.

After run npm install @auth0/nextjs-auth0 the package was automatically added "@auth0/nextjs-auth0": "github:auth0/nextjs-auth0", .

I just edit to

"@auth0/nextjs-auth0": "^1.3.1"

and worked on deployment.

Note: The way the package was installed worked on dev in localhost but broke only on the deployment.

try making a custom build script for your deployment as a temporary workaround:

npm install && npm i @auth0/nextjs-auth0@1.3.1 && npm run build

This can be added under the deployment settings tab using a custom build command for production. Running the specific targeted package version install after npm i should override the problematic version being installed in prod构建命令

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM