In my firebase functions, I created a local package to share code in my angular application and my firebase functions. This seems to break the deploying of my code, as you will see in the log on the bottom.
The folder structure is like this:
/frontend/..
/backend/functions
/shared/..
The package.json of my firebase functions has this entry:
"my-shared": "file:../../shared",
When I import the code from my-shared
, it looks like this:
import { User } from "my-shared/lib/models/user";
The package.json
from the shared folder looks like this:
{
"name": "my-shared",
"version": "1.0.0",
"main": "lib/index.js",
"scripts": {
"build": "tsc",
"prepare": "npm run build",
"watch": "npx tsc --watch"
},
"devDependencies": {
"typescript": "^2.8.3"
},
"files": [
"lib/**/*"
],
"dependencies": {
"json2typescript": "^1.5.0-rc.0"
},
"private": true
}
When I run firebase deploy, I got this error:
Error: Functions did not deploy properly.
Here a snippet of the log when running this:
firebase functions:log --only myFunction
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!
What I did so far:
- npm install in shared
- rm -rf node_modules && npm rm package-lock.json && npm install in backend/functions
- for testing I replaced the absolute path of "my-shared": "file:../../shared"
- tried
npm link
, but as I understand it correctly the line above should also work - update node globally
- spend much time to solve this problem
Is something wrong with my local package or is there a configuration missing? Would be great, if someone could help me here.
By the way, the frontend has the same package.json entry and is compiling successfully.