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: Cannot find module - cross-env #143

Closed
woutersteven opened this issue Sep 27, 2023 · 2 comments
Closed

Error: Cannot find module - cross-env #143

woutersteven opened this issue Sep 27, 2023 · 2 comments

Comments

@woutersteven
Copy link

woutersteven commented Sep 27, 2023

Not entirely sure if it is related to the VSC extension, but it's working outside the extension, so i'll create an issue, maybe somebody knows something. The issue started appearing after firebase-tools 12.2.1. It is working in that version and the versions below it.

In my package.json file, i have:

"functions-deploy": "firebase deploy --only functions",

Which works if i run it manually or when i run it as NPM run. Both of the following work:

firebase deploy --only functions
npm run functions-deploy

If i click on the script in the VSC plugin, i get the following error:

Error: Cannot find module 'C:\Users\...\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\cross-env\dist\bin\cross-env-shell.js'

This error does not appear if i manually run it in a shell. Its triggered by predeploy scripts in firebase.json

  "functions": [
    {
      "source": "functions",
      "codebase": "default",
      "ignore": [
        "node_modules",
        ".git",
        "firebase-debug.log",
        "firebase-debug.*.log"
      ],
      "predeploy": [
        "npm --prefix \"$RESOURCE_DIR\" run lint",
        "npm --prefix \"$RESOURCE_DIR\" run build"
      ]
    }
  ],

Removign the predeploy scripts removes the error, but this is not preferable. Changing the RESOURCE_DIR paths or hard-coding, also doesn't resolve the error. at the moment I'm just running the commands manually.

I'm guessing it could be related to an environment variable that is not available when the VSC extension runs the scripts in package.json, but this is a guess. I'm not entirely sure.

@dtarnawsky
Copy link
Collaborator

It sounds like you would have installed firebase-tools globally using npm install -g firebase-tools however based on the error it cannot find the path or doesnt have access to it. On Windows you would have had to run the command as an admin, so it's possible you would need to run VS Code as admin to have it run firebase tools successfully. Another alternative is to install firebase-tools locally and put npx in front of your commands to run firebase.

@woutersteven
Copy link
Author

Thank you for your reply. No luck so far, I tried starting VSC as administrator by default, but the issue still remains. It's also weird it only shows up in version 12.2.1+, in version 12.2.1 or lower it is working fine, also when VSC is not run as administrator.

Placing npx in front of the command also didn't have the desired effect.

The work-around for me now is to run the command manually, and that's working fine. When I find a solution I will update this comment. Thank you for your suggestions.

@kensodemann kensodemann transferred this issue from ionic-team/vscode-extension May 13, 2024
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