Home > Enterprise >  Why does Firebase not deploy local module?
Why does Firebase not deploy local module?

Time:12-23

Locally I have a npm module which I installed in Firebase functions with npm i --save ../shared/. After the installation I find the folder in node_modules which is a symbolic link. I am able to build the project. So far so good!

But now I cannot deploy the Firebase function. I get the following error in the Functions console:

"message": "Build failed: npm ERR! code ENOENT\nnpm ERR! syscall open\nnpm ERR! path /workspace/node_modules/shared/package.json\nnpm ERR! errno -2\nnpm ERR! enoent ENOENT: no such file or directory, open '/workspace/node_modules/shared/package.json'\nnpm ERR! enoent This is related to npm not being able to find a file.\nnpm ERR! enoent \n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /www-data-home/.npm/_logs/2021-12-20T11_02_22_672Z-debug.log; Error ID: beaf8772"

Probably Firebase doesn't deploy symbolic folders? In firebase.json I updated the predeploy commands to remove the symbolic folder and to copy it:

"predeploy": [
  "rm -r \"$RESOURCE_DIR\"/node_modules/shared",
  "mkdir \"$RESOURCE_DIR\"/node_modules/shared",
  "cp -r ./shared/. \"$RESOURCE_DIR\"/node_modules/shared",
  "npm --prefix \"$RESOURCE_DIR\" run build"
]

The commands do remove the symbolic folder and copy the files. I find them in node_modules.

But this doesnt work too, as I get them same error message again.

"message": "Build failed: npm ERR! code ENOENT\nnpm ERR! syscall open\nnpm ERR! path /workspace/node_modules/shared/package.json\nnpm ERR! errno -2\nnpm ERR! enoent ENOENT: no such file or directory, open '/workspace/node_modules/shared/package.json'\nnpm ERR! enoent This is related to npm not being able to find a file.\nnpm ERR! enoent \n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /www-data-home/.npm/_logs/2021-12-20T11_18_09_566Z-debug.log; Error ID: beaf8772"

How do you do it?

CodePudding user response:

In my case the shared module only contains types. So as workaround I published it to NPM and then installed it as usual.

This workaround works!

https://docs.npmjs.com/cli/v8/commands/npm-publish

Although I am not really happy with that solution it is good enough at the moment. ASAP I will post a better solution.

  • Related