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

Not support node v17 #31514

Closed
bluelovers opened this issue Nov 16, 2021 · 4 comments
Closed

Not support node v17 #31514

bluelovers opened this issue Nov 16, 2021 · 4 comments
Labels
bug Issue was opened via the bug report template.

Comments

@bluelovers
Copy link

What version of Next.js are you using?

12

What version of Node.js are you using?

17

What browser are you using?

xx

What operating system are you using?

windows

How are you deploying your application?

yarn start

Describe the Bug

Package subpath './package.json' is not defined by "exports"

Expected Behavior

no error same as node 16

To Reproduce

use node 17
yarn start

@bluelovers bluelovers added the bug Issue was opened via the bug report template. label Nov 16, 2021
@bluelovers
Copy link
Author

const getPackagePath = (name: string, relativeToPath: string) => {
const packageJsonPath = require.resolve(`${name}/package.json`, {
paths: [relativeToPath],
})
// Include a trailing slash so that a `.startsWith(packagePath)` check avoids false positives
// when one package name starts with the full name of a different package.
// For example:
// "node_modules/react-slider".startsWith("node_modules/react") // true
// "node_modules/react-slider".startsWith("node_modules/react/") // false
return path.join(packageJsonPath, '../')
}

replace to

import { resolvePackageJsonLocation } from '@yarn-tool/resolve-package'
const getPackagePath = (name: string, relativeToPath: string) => {
    const packageJsonPath = resolvePackageJsonLocation(name, {
      paths: [relativeToPath],
    })
    // Include a trailing slash so that a `.startsWith(packagePath)` check avoids false positives
    // when one package name starts with the full name of a different package.
    // For example:
    //   "node_modules/react-slider".startsWith("node_modules/react")  // true
    //   "node_modules/react-slider".startsWith("node_modules/react/") // false
    return path.join(packageJsonPath, '../')
  }

@ljosberinn
Copy link
Contributor

I believe it's not a nextjs issue but specifically React as its the only package throwing. I've written a monkey patch here.

related

@balazsorban44
Copy link
Member

I just tried this and it worked fine.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

4 participants