Closed iwoork closed 2 years ago
Hi, I'm not able to reproduce this. Could you create a minimal reproduction?
Also, could you show the contents of your node_modules/next-auth/package.json
(the one the error mentions)?
I have the same issue. I've just installed the package freshly for a new project. I use yarn. (v2, no pnp)
The package.json contains:
"./providers/*": "./providers/*.js"
If I add the provider manually, it works. (At least the error goes away BUT the next issue will be Cannot POST /api/auth/signin/google
so this might event be something more fundamental)
"./providers/google": "./providers/google.js",
"./providers/*": "./providers/*.js"
Apparently, the star pattern does not work?
I can also confirm this bug, which can also be reproduced with other providers the same way as @iwoork described in his bugreport.
When changing the wildcard into an absolute path it seems to work:
// Default
"./providers/*": "./providers/*.js"
// Fix
".providers/spotify": "./providers/spotify.js",
Could a workaround be to import all providers with their absolute paths? As stated by @reebalazs , The wildcard import seems to be the issue.
System: Windows 11 Node: v12.18.1 npm: 6.14.5
npmPackages: "next": "latest", "next-auth": "^4.0.0-beta.7", "react": "^17.0.2", "react-dom": "^17.0.2"
Contents of package.json from the next-auth folder:
{
"_args": [
[
"next-auth@4.1.2",
"/Users/iwoork/auction"
]
],
"_from": "next-auth@4.1.2",
"_id": "next-auth@4.1.2",
"_inBundle": false,
"_integrity": "sha512-r5Km0eIDgGad+yhegk6OpulAnf7pyxsIpLec3xYB3PIb7F3bUTsvgWm/n/wAvlT0aAF1xKQWOgqhwPjrjte89g==",
"_location": "/next-auth",
"_phantomChildren": {
"regenerator-runtime": "0.13.9"
},
"_requested": {
"type": "version",
"registry": true,
"raw": "next-auth@4.1.2",
"name": "next-auth",
"escapedName": "next-auth",
"rawSpec": "4.1.2",
"saveSpec": null,
"fetchSpec": "4.1.2"
},
"_requiredBy": [
"/",
"/@types/next-auth"
],
"_resolved": "https://registry.npmjs.org/next-auth/-/next-auth-4.1.2.tgz",
"_spec": "4.1.2",
"_where": "/Users/iwoork/auction",
"author": {
"name": "Iain Collins",
"email": "me@iaincollins.com"
},
"bugs": {
"url": "https://github.com/nextauthjs/next-auth/issues"
},
"contributors": [
{
"name": "Balázs Orbán",
"email": "info@balazsorban.com"
},
{
"name": "Nico Domino",
"email": "yo@ndo.dev"
},
{
"name": "Lluis Agusti",
"email": "hi@llu.lu"
}
],
"dependencies": {
"@babel/runtime": "^7.16.3",
"@panva/hkdf": "^1.0.1",
"cookie": "^0.4.1",
"jose": "^4.3.7",
"oauth": "^0.9.15",
"openid-client": "^5.1.0",
"preact": "^10.6.3",
"preact-render-to-string": "^5.1.19",
"uuid": "^8.3.2"
},
"description": "Authentication for Next.js",
"devDependencies": {
"@actions/core": "^1.6.0",
"@babel/cli": "^7.16.0",
"@babel/core": "^7.16.0",
"@babel/plugin-proposal-optional-catch-binding": "^7.16.0",
"@babel/plugin-transform-runtime": "^7.16.4",
"@babel/preset-env": "^7.16.4",
"@babel/preset-react": "^7.16.0",
"@babel/preset-typescript": "^7.16.0",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"@testing-library/react-hooks": "^7.0.2",
"@testing-library/user-event": "^13.5.0",
"@types/node": "^16.11.12",
"@types/nodemailer": "^6.4.4",
"@types/oauth": "^0.9.1",
"@types/react": "^17.0.37",
"@types/react-dom": "^17.0.11",
"@typescript-eslint/parser": "^4.33.0",
"autoprefixer": "^10.4.0",
"babel-jest": "^27.4.2",
"babel-plugin-jsx-pragmatic": "^1.0.2",
"babel-preset-preact": "^2.0.0",
"conventional-changelog-conventionalcommits": "4.6.1",
"cssnano": "^5.0.12",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-standard-with-typescript": "^21.0.1",
"eslint-plugin-jest": "^25.3.0",
"eslint-plugin-node": "^11.1.0",
"fs-extra": "^10.0.0",
"husky": "^7.0.4",
"jest": "^27.4.3",
"jest-watch-typeahead": "^1.0.0",
"msw": "^0.36.3",
"next": "12.0.7",
"postcss-cli": "^9.0.2",
"postcss-nested": "^5.0.6",
"prettier": "2.4.1",
"pretty-quick": "^3.1.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"typescript": "^4.5.2",
"whatwg-fetch": "^3.6.2"
},
"engines": {
"node": "^12.19.0 || ^14.15.0 || ^16.13.0"
},
"eslintConfig": {
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.eslint.json"
},
"extends": [
"standard-with-typescript",
"prettier"
],
"ignorePatterns": [
"node_modules",
"next-env.d.ts",
"types",
".next",
"dist",
"/core",
"/react.js"
],
"globals": {
"localStorage": "readonly",
"location": "readonly",
"fetch": "readonly"
},
"rules": {
"camelcase": "off",
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/strict-boolean-expressions": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/restrict-template-expressions": "off"
},
"overrides": [
{
"files": [
"./**/*test.js"
],
"env": {
"jest/globals": true
},
"extends": [
"plugin:jest/recommended"
],
"plugins": [
"jest"
]
}
]
},
"eslintIgnore": [
"./*.d.ts",
"**/tests",
"**/__tests__"
],
"exports": {
".": "./index.js",
"./jwt": "./jwt/index.js",
"./react": "./react/index.js",
"./core": "./core/index.js",
"./next": "./next/index.js",
"./client/_utils": "./client/_utils.js",
"./providers/*": "./providers/*.js"
},
"files": [
"lib",
"css",
"jwt",
"react",
"next",
"client",
"providers",
"core",
"index.d.ts",
"index.js",
"adapters.d.ts"
],
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/balazsorban44"
},
{
"type": "opencollective",
"url": "https://opencollective.com/nextauth"
}
],
"homepage": "https://next-auth.js.org",
"keywords": [
"react",
"nodejs",
"oauth",
"jwt",
"oauth2",
"authentication",
"nextjs",
"csrf",
"oidc",
"nextauth"
],
"license": "ISC",
"main": "index.js",
"module": "index.js",
"name": "next-auth",
"peerDependencies": {
"nodemailer": "^6.6.5",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"peerDependenciesMeta": {
"nodemailer": {
"optional": true
}
},
"prettier": {
"semi": false
},
"release": {
"branches": [
"+([0-9])?(.{+([0-9]),x}).x",
"main",
{
"name": "beta",
"prerelease": true
},
{
"name": "next",
"prerelease": true
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
[
"@semantic-release/github",
{
"releasedLabels": false,
"successComment": false
}
]
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/nextauthjs/next-auth.git"
},
"scripts": {
"build": "npm run build:js && npm run build:css",
"build:css": "postcss --config config/postcss.config.js src/**/*.css --base src --dir . && node config/wrap-css.js",
"build:js": "npm run clean && npm run generate-providers && tsc && babel --config-file ./config/babel.config.js src --out-dir . --extensions \".tsx,.ts,.js,.jsx\"",
"clean": "rm -rf client css lib providers core jwt react next index.d.ts index.js adapters.d.ts",
"dev": "cd app && npm run dev",
"dev:setup": "npm i && npm run generate-providers && npm run build:css && cd app && npm i",
"generate-providers": "node ./config/generate-providers.js",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepublishOnly": "npm run build",
"test": "jest --config ./config/jest.config.js",
"test:ci": "npm run lint && npm run test -- --ci",
"version:pr": "node ./config/version-pr",
"watch:css": "postcss --config config/postcss.config.js --watch src/**/*.css --base src --dir ."
},
"types": "index.d.ts",
"version": "4.1.2"
}
@iwoork, where are those _
fields coming from? :thinking: This is how the package.json
should look like in your case: https://unpkg.com/browse/next-auth@4.1.2/package.json
@reebalazs This should be allowed https://nodejs.org/api/packages.html#subpath-patterns
Might be an issue with Yarn 2. I have generally bad experience with both Yarn 2 and above. If this turns out to be a related issue, I'm inclined to not spend time on it.
I'll check if this can be Next.js/Webpack related.
Update: @iwoork could you update your Node. js version to at least 14.13.0
? it seems to be the issue.
@reebalazs could you try something else than Yarn 2 and see if your issue persists?
@balazsorban44 thank you, this is actually related to the node version. Although I am using v14, the shell that I was testing from fell back to v12 by mistake. v14 has no problems with the subpath patterns.
So luckily this is not yarn2 specific. (Since NextJS and Vercel supports yarn2 at least in node_modules mode, there is no reason for next-auth to fail.)
Any other reporter can you please confirm that the problem goes away with Node >= v14?
Thanks all. I'm on v14.5.0 and yet having the issue.
@iwoork Subpath patterns Added in: v14.13.0, v12.20.0
Upgrade!
Reference: https://nodejs.org/api/packages.html#subpath-patterns
@iwoork https://github.com/nextauthjs/next-auth/issues/3652#issuecomment-1015026217
Update: @iwoork could you update your Node. js version to at least 14.13.0? it seems to be the issue.
I'm going to close this assuming the issue is resolved with the suggested update.
Note that upgrading Node 14.5.0 to at least 14.13.0 is not a breaking change and should be safe to do.
I was facing this issue. I was using the "next-auth": "^4.18.7" version. my node version was 14.0.0. when I update this version to 18.12.1 then the issue is resolved.
@balazsorban44 I still have this issue with ts-node, "@auth/core": "^0.8.2", "@types/node": "^18.16.16",
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './providers/google' is not defined by "exports" in D:...\node_modules\@auth\core\package.json
Description 🐜
I've followed the upgrade path to v4 and made the following changes:
next-auth/client
tonext-auth/react
Provider
toSessionProvider
[session]
references to{data: session}
Is this a bug in your own project?
Yes
How to reproduce ☕️
Install the latest next-auth Use cognito as provider
Screenshots / Logs 📽
Environment 🖥
System: OS: macOS 11.6 CPU: (8) x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz Memory: 844.17 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 14.5.0 - /usr/local/bin/node Yarn: 1.22.17 - ~/auction/node_modules/.bin/yarn npm: 6.14.5 - /usr/local/bin/npm Browsers: Chrome: 97.0.4692.71 Safari: 15.0 npmPackages: next: ^12.0.8 => 12.0.8 next-auth: ^4.1.2 => 4.1.2 react: ^17.0.2 => 17.0.2
Contributing 🙌🏽
Yes, I am willing to help solve this bug in a PR