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

yarn2 Vercel build failed - No Next.js version could be detected in your project #5280

Open
fmal opened this issue Oct 8, 2020 · 12 comments

Comments

@fmal
Copy link

fmal commented Oct 8, 2020

I'm using yarn 2 (berry) in PnP mode with offline cache. Project is setup as a monorepo with workspaces. One of the workspaces (site) is a next.js app and obviously next.js is specified as a dependency.
This is the deployed files tree:

Screenshot 2020-10-09 at 00 10 30

When deploying the monorepo with Vercel CLI i get the following error in the logs:

Error: No Next.js version could be detected in your project. Make sure "next" is installed in "dependencies" or "devDependencies"

Related discussion: #4910

@markozxuu
Copy link
Contributor

Hi @fmal 👋 In this particular case I can't do much. Vercel is currently not supported for Yarn v2 Berry 😿

@kachkaev
Copy link

kachkaev commented Oct 18, 2020

Is there a workaround (say, via vercel.json)? Trying to migrate njt to yarn berry and am getting the same error.

Screenshot of vercel dashboard with logs

UPD: Just found this page in Vercel’s knowledge base: https://vercel.com/knowledge/does-vercel-support-yarn-2

@SagnikPradhan
Copy link
Contributor

Update, the only current workaround is to use the node-modules linker. Something is better than nothing ya know.

@gurkerl83
Copy link

gurkerl83 commented Nov 23, 2020

The option to set the node linker from "pnp" (default) to "node-modules" works, but this causes a different problem.

A fixed insert in the .yarnrc.yml file will cause the option to be set back and forth when using the plug and play mode on a local development machine.

The node-linker option "node-modules" should only be necessary when deploying on the Vercel infrastructure.

Due to several tests performed on one project, it seems that a Vercel deployment ignores all yarn install steps, such as pre-install before install. Setting the node-linker option at this point is not considered for a deployment! It seems that only the script "vercel-build" within a script of the same name defined in package.json can get overridden.

After a brief look into @vercel/next, it becomes clear that there is a way to send your install commands to the deployment process. The definition of these steps seems possible via the dashboard of a project, but I did not try this.

The following was tested using the vercel cli.

The advantage of the dynamic variant is that the node linker gets set when loading the source code into the infrastructure before initiating the dependencies' installation. In the example, an installation of Yarn Barry also gets executed.

A definition of a pre-install command looks like this.

vercel.json or now.json

{
  "version": 2,
  "public": true,
  "builds": [
    {
      "src": "package.json",
      "use": "@vercel/next",
      "config": {
        "installCommand": "yarn set version berry && yarn plugin import workspace-tools && yarn config set nodeLinker node-modules && yarn install"
      }
    }
  ]
}

Maybe this helps in some way.

Thx!

@merceyz
Copy link

merceyz commented Nov 24, 2020

You can use env variables to set the node linker, if you define YARN_NODE_LINKER="node-modules" Yarn will use that instead of whatever is in your config. Ref note at the top here https://yarnpkg.com/configuration/yarnrc

@gurkerl83
Copy link

@merceyz Even better, I will try that, Thx!

kodiakhq bot pushed a commit that referenced this issue Dec 14, 2020
…es"` env var when executing `yarn` (#5552)

### Related Issues

* https://vercel.com/knowledge/does-vercel-support-yarn-2
* #4223
* #4910
* #5136
* #5280

### 📋 Checklist

<!--
  Please keep your PR as a Draft until the checklist is complete
-->

#### Tests

- [x] The code changed/added as part of this PR has been covered with tests
- [x] All tests pass locally with `yarn test-unit`

#### Code Review

- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
@TooTallNate
Copy link
Member

Hello friends. I wanted to notify you that we have added support for Yarn v2 in our official Runtimes (@vercel/next, @vercel/node and @vercel/static-build, specifically, see #5552). Currently the update is available on the "canary" release channel.

If you would like to try out the Yarn v2 support before it hits the stable release channel, you can run the following command if you are using the CLI:

$ vc -b FORCE_BUILDER_TAG=canary

If you are using the Git integration to trigger your deployments, then you can define the FORCE_BUILDER_TAG environment variable in your Project's environment variables setting on the Vercel dashboard.

Please let me know if it works for you or if you bump into any issues!

@kachkaev
Copy link

kachkaev commented Dec 20, 2020

Great news @TooTallNate 🎉 I just tried setting FORCE_BUILDER_TAG=canary in my project’s Vercel dashboard and it worked! WDYT of updating the knowledge base? It still says that Yarn 2 is not supported.


Vercel kowledge base screenshot (yarn 2 page)

@rayshan
Copy link

rayshan commented Jan 13, 2021

Confirming that it worked for my project as well. All I had to do is add the environment variable FORCE_BUILDER_TAG=canary. I was having a hard time making yarn 2 berry work on Netlify, even with @netlify/plugin-nextjs. Vercel is now pain-free.

ofhouse pushed a commit to milliHQ/terraform-aws-next-js that referenced this issue Mar 13, 2021
…es"` env var when executing `yarn` (#5552)

### Related Issues

* https://vercel.com/knowledge/does-vercel-support-yarn-2
* vercel/vercel#4223
* vercel/vercel#4910
* vercel/vercel#5136
* vercel/vercel#5280

### 📋 Checklist

<!--
  Please keep your PR as a Draft until the checklist is complete
-->

#### Tests

- [x] The code changed/added as part of this PR has been covered with tests
- [x] All tests pass locally with `yarn test-unit`

#### Code Review

- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
@osdiab
Copy link

osdiab commented May 7, 2021

A documentation question: the page on the site says that Yarn 2 is only supported for static builds, but is that referring specifically to PnP or is yarn 2 functional when using the node linker? If it's the former, I think the docs should be updated to specify that specifically PnP doesn't work, not all of yarn 2.

@stritti
Copy link

stritti commented Aug 12, 2021

Same problem on vuepress-next.
So had to switch to Netlify :(

@Hsabonchi
Copy link

I solved it by changing "next@^12.3.0" to "next@12.3.0" on the yarn.lock file

onlinehub0808 added a commit to onlinehub0808/terrafirn-aws-next.js that referenced this issue Mar 1, 2023
…es"` env var when executing `yarn` (#5552)

### Related Issues

* https://vercel.com/knowledge/does-vercel-support-yarn-2
* vercel/vercel#4223
* vercel/vercel#4910
* vercel/vercel#5136
* vercel/vercel#5280

### 📋 Checklist

<!--
  Please keep your PR as a Draft until the checklist is complete
-->

#### Tests

- [x] The code changed/added as part of this PR has been covered with tests
- [x] All tests pass locally with `yarn test-unit`

#### Code Review

- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
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