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

On Windows Extension dependencies do not get installed. PR created ✔ #5372

Closed
stfsy opened this issue Dec 27, 2022 · 2 comments
Closed

On Windows Extension dependencies do not get installed. PR created ✔ #5372

stfsy opened this issue Dec 27, 2022 · 2 comments

Comments

@stfsy
Copy link
Contributor

stfsy commented Dec 27, 2022

[REQUIRED] Environment info

firebase-tools: 11.19.0

Platform: Windows

[REQUIRED] Test case

#5371 contains a fix and a unit test.

[REQUIRED] Steps to reproduce

  • Use a Windows machine
  • Install firebase-tools
  • Install a firebase extension like firestore-counter
  • Start the emulator
  • Verify that no node_modules exist in extension folder

[REQUIRED] Expected behavior

npm install was executed in the functions directory of an extension

[REQUIRED] Actual behavior

npm install gets executed, however, the path passed to child_process.spawn is not valid on Windows machines as it contains multiple forward slashs /. Normally Node would handle platform dependent paths, however in this case the path is directly passed to CMD on Windows.

const npmInstall = spawn.sync("npm", ["--prefix", `/${sourceCodePath}/functions/`, "install"], {
encoding: "utf8",
});

We can fix the behaviour by having Node resolve the path first and then the passing the path to child_process.spawn as cwd.

https://github.com/stfsy/firebase-tools/blob/f6ab8a52a1f3c0f802ed4d8161fdf54fd04e747a/src/emulator/extensionsEmulator.ts#L174-L178

Therefore, I already provided PR #5371 which with an additional test case to ensure that dependencies get installed on Windows.

@stfsy stfsy added the bug label Dec 27, 2022
@stfsy stfsy changed the title On Windows Extension dependencies do not get installed On Windows Extension dependencies do not get installed. PR created ✔ Dec 27, 2022
joehan added a commit that referenced this issue Dec 28, 2022
@joehan
Copy link
Contributor

joehan commented Dec 29, 2022

Thanks for the contribution!

@joehan joehan closed this as completed Dec 29, 2022
@hajsf
Copy link

hajsf commented Jan 15, 2023

I'm getting the below error:

~ Let's make sure your Firebase CLI is ready...
undefined:1


SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at ChildProcess.<anonymous> (C:\snapshot\firepit\welcome.js:115:27)
    at ChildProcess.emit (node:events:527:28)
    at maybeClose (node:internal/child_process:1092:16)
    at Socket.<anonymous> (node:internal/child_process:451:11)
    at Socket.emit (node:events:527:28)
    at Pipe.<anonymous> (node:net:709:12)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants