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

Unable to run a nodejs project as yarn is not present in path #456

Closed
anoop2811 opened this issue Sep 21, 2021 · 7 comments
Closed

Unable to run a nodejs project as yarn is not present in path #456

anoop2811 opened this issue Sep 21, 2021 · 7 comments

Comments

@anoop2811
Copy link

What happened?

I have an application which requires yarn to start at run time but yarn is not present in the path in the run image.

  • What were you attempting to do?
    Run application called backstage (backstage.io)

  • What did you expect to happen?
    Expected it to run using the yarn start

  • What was the actual behavior? Please provide log output, if possible.
    bash: yarn: command not found

Build Configuration

  • What platform (pack, kpack, tekton buildpacks plugin, etc.) are you
    using? Please include a version.
    pack build backstage-buildpack --path . --builder paketobuildpacks/builder:full

  • What buildpacks are you using? Please include versions.
    Was using the packeto nodejs buildpack

  • What builder are you using? If custom, can you provide the output from pack inspect-builder <builder>?
    paketobuildpacks/builder:full

  • Can you provide a sample app or relevant configuration (buildpack.yml,
    nginx.conf, etc.)?
    package copy.json.txt

Checklist

  • [x ] I have included log output.
  • [x ] The log output includes an error message.
  • [x ] I have included steps for reproduction.
@arjun024
Copy link
Member

Hi @anoop2811, thanks for the report. I have a couple of questions for you.

(1) Do you have a yarn.lock at the root of your application? This is how the nodejs composite buildpack determines if package manager to use is yarn or npm. npm is the default package manager for all node.js applications unless a yarn.lock is present at the root. See sample app https://github.com/paketo-buildpacks/samples/tree/main/nodejs/yarn

(2) Are you expecting to use yarn2? If yes, paketo does not have yarn2 support yet. Please see the discussion here (paketo-buildpacks/yarn#19)

@anoop2811
Copy link
Author

Hi @arjun024 , yes, I do have a yarn.lock file at the root of the application and I am not using yarn2.

@arjun024
Copy link
Member

Could you provide the build logs and a sample app if possible?

@anoop2811
Copy link
Author

anoop2811 commented Sep 21, 2021

Hi @arjun024,
Please find the sample project here: https://github.com/anoop2811/backstage
Build logs attached:
build.log.txt
Run error:

docker run -p 3000:3000 -it  backstage-buildpack
bash: yarn: command not found

@arjun024
Copy link
Member

Thanks for the sample and logs. As of now, the yarn-start buildpack only makes yarn available to the build stage and not in the final built application image. I think it's reasonable for the nodejs buildpack to support a case where the start command is of the syntax yarn workspace <workspace_name> <command>. I'll work on a change to get yarn available at launch and try to get it released soon.

In the meantime, you can make use of the build-plan buildpack. You need a plan.toml at the root of the application asking yarn to be available at launch time i.e. the final application image. See e.g. here

arjun024 added a commit to paketo-buildpacks/yarn-start that referenced this issue Sep 22, 2021
This change adds supports to cases where yarn is used in start
commands. A common example is the use of yarn workspaces or
frameworks (like lerna) built on top of yarn workspaces.

A chose yarn command is run in a particular workspace using the
following syntax:
`yarn workspace <workspace_name> <command>`
See https://classic.yarnpkg.com/en/docs/cli/workspace/
This requires the yarn tool to be available at launch time.
See added integration test for an example.

Also, see issue paketo-buildpacks/nodejs#456
arjun024 added a commit to paketo-buildpacks/npm-start that referenced this issue Sep 22, 2021
This change is mostly cosmetic as node-engine buildpack provides both
node and npm when node is requested.
paketo-buildpacks/nodejs#456

This also makes the API consistent with the changes introduced in
paketo-buildpacks/yarn-start#143 to
yarn-install.
@anoop2811
Copy link
Author

Thanks @arjun024 .
I tried addind the following plan.toml
plan.toml.txt
and tried again using the following command:
pack build backstage-buildpack --path . --builder paketobuildpacks/builder:full -b paketo-buildpacks/[email protected] -b paketo-community/[email protected]

but I still get the same error

thitch97 added a commit to paketo-buildpacks/yarn-start that referenced this issue Sep 24, 2021
This change adds supports to cases where yarn is used in start
commands. A common example is the use of yarn workspaces or
frameworks (like lerna) built on top of yarn workspaces.

A chose yarn command is run in a particular workspace using the
following syntax:
`yarn workspace <workspace_name> <command>`
See https://classic.yarnpkg.com/en/docs/cli/workspace/
This requires the yarn tool to be available at launch time.
See added integration test for an example.

Also, see issue paketo-buildpacks/nodejs#456

Co-authored-by: Tim Hitchener <[email protected]>
@arjun024
Copy link
Member

@anoop2811 With v0.9.0 of the nodejs buildpack, you should be able to have yarn available on the application image. See example app. Feel free to reopen the issue if the problem persists.

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

2 participants