firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

Dev dependencies are also installed

Open phcoliveira opened this issue 2 years ago • 0 comments

[REQUIRED] Environment info

firebase-tools: 11.3.0

Platform: macOS

[REQUIRED] Test case

{
    "name": "@all-aboard/firebase",
    "version": "0.0.0",
    "private": true,
    "scripts": {
        "build:watch": "tsc --watch",
        "build": "tsc",
        "clean": "rm -rf .turbo lib node_modules",
        "deploy": "firebase deploy",
        "dev": "npm run build && npm run emulators:start",
        "emulators:start": "firebase emulators:start",
        "lint:fix": "npm run lint -- --fix",
        "lint": "eslint . --max-warnings=0",
        "logs": "firebase functions:log",
        "serve": "npm run build && firebase emulators:start",
        "shell": "npm run build && firebase functions:shell",
        "start": "npm run shell",
        "test:watch": "npm run test -- --watch",
        "test": "jest"
    },
    "engines": {
        "node": "16"
    },
    "main": "lib/index.js",
    "dependencies": {
        "firebase-admin": "10.3.0",
        "firebase-functions": "3.22.0"
    },
    "devDependencies": {
        "@all-aboard/eslint-config": "*", // Just for the sake of an example
        "@all-aboard/firebase-js-sdk": "file:../../packages/firebase-js-sdk",
        "@all-aboard/jest": "file:../../packages/jest",
        "@all-aboard/typescript": "file:../../packages/typescript",
        "@firebase/rules-unit-testing": "2.0.3",
        "firebase-functions-test": "0.2.3"
    }
}

[REQUIRED] Steps to reproduce

  1. Have a basic monorepo setup, with apps/* and packages/*.
  2. Use firebase init to start a new app inside apps/*.
  3. Add a local package from your monorepo to the functions app as devDependency.
  4. Try to deploy the functions.

[REQUIRED] Expected behavior

According to these docs, the deployment of Firebase Functions should only install the dependencies used in production.

[REQUIRED] Actual behavior

Firebase Functions tries to install devDependencies as well. Yes, I know that using file:(...) works, as it is denoted in my file package.json shown above. I am just trying to make a point here.

Starting from NPM's version 8, instead of npm install --production, it should be npm install --omit=dev. Perhaps I am missing something here, but the docs have lead me to believe that devDependencies should not be installed.

~/Work/Robocorp/all-aboard/apps/firebase/ [main+*] npm run deploy

> @all-aboard/[email protected] deploy
> firebase deploy


=== Deploying to 'all-aboard-staging'...

i  deploying database, functions
Running command: npm --prefix "$RESOURCE_DIR" run lint

> @all-aboard/[email protected] lint
> eslint . --max-warnings=0

Running command: npm --prefix "$RESOURCE_DIR" run build

> @all-aboard/[email protected] build
> tsc

✔  functions: Finished running predeploy script.
i  database: checking rules syntax...
✔  database: rules syntax for database all-aboard-staging-default-rtdb is valid
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
i  artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled...
✔  functions: required API cloudbuild.googleapis.com is enabled
✔  functions: required API cloudfunctions.googleapis.com is enabled
✔  artifactregistry: required API artifactregistry.googleapis.com is enabled
i  functions: preparing codebase default for deployment
i  functions: preparing . directory for uploading...
i  functions: packaged /Users/paulo/Work/Robocorp/all-aboard/apps/firebase (14.71 KB) for uploading
✔  functions: . folder uploaded successfully
i  database: releasing rules...
✔  database: rules for database all-aboard-staging-default-rtdb released successfully
i  functions: updating Node.js 16 function helloWorld(us-central1)...
Build failed: npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@all-aboard%!f(MISSING)eslint-config - Not found
npm ERR! 404 
npm ERR! 404  '@all-aboard/eslint-config@*' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /www-data-home/.npm/_logs/2022-07-25T09_07_17_558Z-debug-0.log; Error ID: b0ba1f57

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

Error: There was an error deploying functions
npm ERR! Lifecycle script `deploy` failed with error: 
npm ERR! Error: command failed 
npm ERR!   in workspace: @all-aboard/[email protected] 
npm ERR!   at location: /Users/paulo/Work/Robocorp/all-aboard/apps/firebase

phcoliveira avatar Jul 25 '22 09:07 phcoliveira