angular / angular/angularfire

Function deployment not uploading referenced package.json file when built with @angular/fire:deploy

Offen
#3,283 1 Kommentar 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
7.8k
Forks
2.2k
Ø Merge
22 Std. 28 Min.
Gemergte PRs (30 T.)
6

Beschreibung

### Version info

**Angular:** 14.2.0

**Firebase:** 11.15.0

**AngularFire:** 7.4.1

**Other (e.g. Ionic/Cordova, Node, browser, operating system):**

### How to reproduce these conditions
Use `@angular/fire:deploy` for an Angular Universal app

**Failing test unit, Stackblitz demonstrating the problem**

**Steps to set up and reproduce**
Use an Nx workspace and add Angular Universal, then include `@angular/fire:deploy` builder (in Nx terms "executor") in `project.json`:
```json
"deploy": {
"executor": "@angular/fire:deploy",
"options": {
"ssr": true,
"firebaseProject": "my-project",
"functionsNodeVersion": 16,
"firebaseHostingSite": "my-site"
},
"configurations": {
"production": {
"browserTarget": "my-app:build:production",
"serverTarget": "my-app:server:production"
}
}
},
```
This generates a production build in the `dist` folder with the following structure:
```
dist /
my-app /
dist /
my-app /
browser
server
node_modules /
index.js
package.json
package-lock.json
```

In the `package.json` file that resides in the `dist` folder is a reference like so:
```
{
// [...]
"my-app": "file:../.."
}
```
The firebase configuration is set up like so:
```json
{
"functions": [
{
"source": "dist/my-app",
"codebase": "default",
"ignore": ["node_modules"]
}
]
}
```

Upon running `firebase deploy --only functions` it errors out (see section below for logs). It seems files outside the `source` are not uploaded to firebase functions and so `@angular/fire:deploy` can't be used to deploy functions.

I can confirm this with the following steps. I remove the line `"my-app": "file:../.."` from the generated `package.json` and remove the `node_modules` and `package-lock.json` in the `dist` folder. Then I run `npm install` in the `dist` folder. When done, I run `firebase deploy --only functions` and it works.

**Sample data and security rules**

### Debug output

** Errors in the JavaScript console **
When running `firebase deploy --only functions` the following output is generated:
```
Build failed: npm ERR! code EUSAGE
npm ERR!
npm ERR! The `npm ci` command can only install with an existing package-lock.json or
npm ERR! npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or
npm ERR! later to generate a package-lock.json file, then try again.
npm ERR!
npm ERR! Clean install a project
npm ERR!
npm ERR! Usage:
npm ERR! npm ci
npm ERR!
npm ERR! Options:
npm ERR! [--no-audit] [--foreground-scripts] [--ignore-scripts]
npm ERR! [--script-shell ]
npm ERR!
npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
npm ERR!
npm ERR! Run "npm help ci" for more info

npm ERR! A complete log of this run can be found in:
npm ERR!

Functions deploy had errors with the following functions:
ssr(us-central1)
i functions: cleaning up build files...

Error: There was an error deploying functions
```

** Output from `firebase.database().enableLogging(true);` **

** Screenshots **

### Expected behavior
`@angular/fire:deploy` should generate output that can be uploaded to functions as is.

### Actual behavior
Functions cannot be deployed because the reference in the generated `package.json` is outside the `source` folder.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit der @angular/fire:deploy-Builder-Konfiguration in project.json und untersuche das generierte dist/my-app/package.json, insbesondere dessen file:../..-Referenz. Reproduziere dies mit firebase deploy --only functions und überprüfe, dass die generierte Ausgabe bereitgestellt werden kann, ohne auf Dateien außerhalb der konfigurierten functions-Quelle zu verweisen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, firebase, node.js, typescript
Bereich
backend, cloud, devops
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.