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

ERROR: @fastly/js-compute not found in package.json. #359

Closed
timsuchanek opened this issue Jul 30, 2021 · 3 comments
Closed

ERROR: @fastly/js-compute not found in package.json. #359

timsuchanek opened this issue Jul 30, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@timsuchanek
Copy link

Version 0.36.0

What happened
Even though I install @fastly/js-compute via yarn, I still get the following error when running fastly compute publish:

ERROR: `@fastly/js-compute` not found in package.json.

To fix this error, run the following command:

        $ npm install --save-dev @fastly/js-compute

Although it's definitely in my package.json and installed.
When I run npm install, it then works.

@timsuchanek timsuchanek added the bug Something isn't working label Jul 30, 2021
@Integralist
Copy link
Collaborator

Hi @timsuchanek thanks for raising this issue (and thanks for your patience). I've been discussing internally with our team about adding support for Yarn. It's now on our radar and I'll update you once I've got some more feedback. At the moment there doesn't appear to be any serious blockers to implementing this, it's simply a case of getting it prioritised accordingly.

@kailan kailan pinned this issue Aug 6, 2021
@JakeChampion
Copy link
Contributor

JakeChampion commented Sep 2, 2021

This issue also happens if you have a monorepo where the @fastly/js-compute package is only installed in the root of the monorepo and not in any of the compute-at-edge projects directly

I was looking into how to confidently know if the package is available for use and the solution which works for all package managers and for monorepos/workspaces is to try and require the package and exit with a non-zero code if it failed:

node -e "try {require('@fastly/js-compute');process.exit(0)} catch {process.exit(1)}"

This also works if @fastly/js-compute was globally installed.

We could replace the npm command in this function with the node command:

func checkPackageDependencyExists(name string) bool {
// gosec flagged this:
// G204 (CWE-78): Subprocess launched with variable
// Disabling as the variables come from trusted sources.
/* #nosec */
err := exec.Command("npm", "list", "--json", "--depth", "0", name).Run()
return err == nil
}

@Integralist
Copy link
Collaborator

As of the CLI v1.3.0 (2021-12-01) Yarn should now be supported: #480

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants