Skip to content

Deployment fails with ERR_PACKAGE_PATH_NOT_EXPORTED for v2/auth on Windows #8837

Closed

Description

@jhonjazzbass

[REQUIRED] Environment info

firebase-tools:
14.9.0

Platform:
Windows

[REQUIRED] Test case

My functions/package.json file:

JSON

{
"name": "functions",
"description": "Cloud Functions for Firebase",
"main": "index.js",
"dependencies": {
"firebase-admin": "^12.6.0",
"firebase-functions": "^6.0.1"
},
"engines": {
"node": "20"
},
"private": true
}

My functions/index.js file:

JavaScript

const admin = require("firebase-admin");

// This is the documented import method for this SDK version
const { onUserCreated } = require("firebase-functions/v2/auth");

admin.initializeApp();

exports.setupNewUser = onUserCreated((user) => {
console.log(New user created: ${user.uid});
return;
});

[REQUIRED] Steps to reproduce

On a Windows machine with Node.js v20 (LTS) installed, create a new empty folder.

Run firebase init functions.

Link it to an existing Firebase project.

When prompted, choose JavaScript as the language.

Replace the contents of functions/package.json and functions/index.js with the code provided in the "Test case" section above.

Navigate into the functions directory (cd functions).

Run npm install.

Run firebase deploy --only functions

[REQUIRED] Expected behavior

The deployment command should complete successfully without errors.

[REQUIRED] Actual behavior

The deployment fails during the code analysis phase with the error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './v2/auth' is not defined by "exports". This occurs even in a completely clean project directory with the latest dependencies and the LTS version of Node.js.

PS C:\Users\jhona\Desktop\proyecto-final\functions> firebase deploy --only functions --debug
[2025-07-12T00:00:43.605Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2025-07-12T00:00:43.609Z] > authorizing via signed-in user ([email protected])
[2025-07-12T00:00:43.609Z] [iam] checking project smart-food-ai for permissions ["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]
[2025-07-12T00:00:43.614Z] Checked if tokens are valid: true, expires at: 1752281309201
[2025-07-12T00:00:43.615Z] Checked if tokens are valid: true, expires at: 1752281309201
[2025-07-12T00:00:43.619Z] >>> [apiv2][query] POST https://cloudresourcemanager.googleapis.com/v1/projects/smart-food-ai:testIamPermissions [none]
[2025-07-12T00:00:43.619Z] >>> [apiv2][(partial)header] POST https://cloudresourcemanager.googleapis.com/v1/projects/smart-food-ai:testIamPermissions x-goog-quota-user=projects/smart-food-ai
[2025-07-12T00:00:43.620Z] >>> [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/smart-food-ai:testIamPermissions {"permissions":["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]}
[2025-07-12T00:00:44.799Z] <<< [apiv2][status] POST https://cloudresourcemanager.googleapis.com/v1/projects/smart-food-ai:testIamPermissions 200
[2025-07-12T00:00:44.800Z] <<< [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/smart-food-ai:testIamPermissions {"permissions":["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]}
[2025-07-12T00:00:44.800Z] Checked if tokens are valid: true, expires at: 1752281309201
[2025-07-12T00:00:44.801Z] Checked if tokens are valid: true, expires at: 1752281309201
[2025-07-12T00:00:44.801Z] >>> [apiv2][query] POST https://iam.googleapis.com/v1/projects/smart-food-ai/serviceAccounts/[email protected]:testIamPermissions [none]
[2025-07-12T00:00:44.801Z] >>> [apiv2][body] POST https://iam.googleapis.com/v1/projects/smart-food-ai/serviceAccounts/[email protected]:testIamPermissions {"permissions":["iam.serviceAccounts.actAs"]}
[2025-07-12T00:00:46.034Z] <<< [apiv2][status] POST https://iam.googleapis.com/v1/projects/smart-food-ai/serviceAccounts/[email protected]:testIamPermissions 200
[2025-07-12T00:00:46.035Z] <<< [apiv2][body] POST https://iam.googleapis.com/v1/projects/smart-food-ai/serviceAccounts/[email protected]:testIamPermissions {"permissions":["iam.serviceAccounts.actAs"]}

=== Deploying to 'smart-food-ai'...

i deploying functions
[2025-07-12T00:00:46.041Z] Checked if tokens are valid: true, expires at: 1752281309201
[2025-07-12T00:00:46.041Z] Checked if tokens are valid: true, expires at: 1752281309201
[2025-07-12T00:00:46.041Z] >>> [apiv2][query] GET https://cloudresourcemanager.googleapis.com/v1/projects/smart-food-ai [none]
[2025-07-12T00:00:46.303Z] <<< [apiv2][status] GET https://cloudresourcemanager.googleapis.com/v1/projects/smart-food-ai 200
[2025-07-12T00:00:46.304Z] <<< [apiv2][body] GET https://cloudresourcemanager.googleapis.com/v1/projects/smart-food-ai {"projectNumber":"636331493711","projectId":"smart-food-ai","lifecycleState":"ACTIVE","name":"smart-food-ai","labels":{"firebase":"enabled","firebase-core":"disabled"},"createTime":"2025-07-07T19:46:42.647129Z"}
i functions: preparing codebase default for deployment
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...
[2025-07-12T00:00:46.308Z] Checked if tokens are valid: true, expires at: 1752281309201
[2025-07-12T00:00:46.309Z] Checked if tokens are valid: true, expires at: 1752281309201
[2025-07-12T00:00:46.309Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/smart-food-ai/adminSdkConfig [none]
[2025-07-12T00:00:46.757Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/smart-food-ai/adminSdkConfig 200
[2025-07-12T00:00:46.758Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/smart-food-ai/adminSdkConfig {"projectId":"smart-food-ai","storageBucket":"smart-food-ai.firebasestorage.app"}
[2025-07-12T00:00:46.759Z] Checked if tokens are valid: true, expires at: 1752281309201
[2025-07-12T00:00:46.760Z] Checked if tokens are valid: true, expires at: 1752281309201
[2025-07-12T00:00:46.760Z] >>> [apiv2][query] GET https://runtimeconfig.googleapis.com/v1beta1/projects/smart-food-ai/configs [none]
[2025-07-12T00:00:47.367Z] <<< [apiv2][status] GET https://runtimeconfig.googleapis.com/v1beta1/projects/smart-food-ai/configs 200
[2025-07-12T00:00:47.368Z] <<< [apiv2][body] GET https://runtimeconfig.googleapis.com/v1beta1/projects/smart-food-ai/configs {"configs":[{"name":"projects/smart-food-ai/configs/openai"}]}
[2025-07-12T00:00:47.370Z] Checked if tokens are valid: true, expires at: 1752281309201
[2025-07-12T00:00:47.371Z] Checked if tokens are valid: true, expires at: 1752281309201
[2025-07-12T00:00:47.372Z] >>> [apiv2][query] GET https://runtimeconfig.googleapis.com/v1beta1/projects/smart-food-ai/configs/openai/variables [none]
[2025-07-12T00:00:48.266Z] <<< [apiv2][status] GET https://runtimeconfig.googleapis.com/v1beta1/projects/smart-food-ai/configs/openai/variables 200
[2025-07-12T00:00:48.267Z] <<< [apiv2][body] GET https://runtimeconfig.googleapis.com/v1beta1/projects/smart-food-ai/configs/openai/variables {"variables":[{"name":"projects/smart-food-ai/configs/openai/variables/key","updateTime":"2025-07-08T22:21:16.021970267Z"}]}
[2025-07-12T00:00:48.268Z] Checked if tokens are valid: true, expires at: 1752281309201
[2025-07-12T00:00:48.268Z] Checked if tokens are valid: true, expires at: 1752281309201
[2025-07-12T00:00:48.269Z] >>> [apiv2][query] GET https://runtimeconfig.googleapis.com/v1beta1/projects/smart-food-ai/configs/openai/variables/key [none]
[2025-07-12T00:00:48.634Z] <<< [apiv2][status] GET https://runtimeconfig.googleapis.com/v1beta1/projects/smart-food-ai/configs/openai/variables/key 200
[2025-07-12T00:00:48.635Z] <<< [apiv2][body] GET https://runtimeconfig.googleapis.com/v1beta1/projects/smart-food-ai/configs/openai/variables/key {"name":"projects/smart-food-ai/configs/openai/variables/key","updateTime":"2025-07-08T22:21:16.021970267Z","text":""}
[2025-07-12T00:00:48.638Z] Validating nodejs source
[2025-07-12T00:00:50.595Z] > [functions] package.json contents: {
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "20"
},
"main": "index.js",
"dependencies": {
"firebase-admin": "^12.6.0",
"firebase-functions": "^6.0.1"
},
"private": true
}
[2025-07-12T00:00:50.597Z] Building nodejs source
i functions: Loading and analyzing source code for codebase default to determine what to deploy
[2025-07-12T00:00:50.599Z] Could not find functions.yaml. Must use http discovery
[2025-07-12T00:00:50.625Z] Found firebase-functions binary at 'C:\Users\jhona\Desktop\proyecto-final\functions\node_modules.bin\firebase-functions'
Serving at port 8717

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './v2/auth' is not defined by "exports" in C:\Users\jhona\Desktop\proyecto-final\functions\node_modules\firebase-functions\package.json
at exportsNotFound (node:internal/modules/esm/resolve:322:10)
at packageExportsResolve (node:internal/modules/esm/resolve:670:9)
at resolveExports (node:internal/modules/cjs/loader:636:36)
at Module._findPath (node:internal/modules/cjs/loader:716:31)
at Module._resolveFilename (node:internal/modules/cjs/loader:1198:27)
at Module._load (node:internal/modules/cjs/loader:1043:27)
at Module.require (node:internal/modules/cjs/loader:1298:19)
at require (node:internal/modules/helpers:182:18)
at Object. (C:\Users\jhona\Desktop\proyecto-final\functions\index.js:4:27)
at Module._compile (node:internal/modules/cjs/loader:1529:14) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

[2025-07-12T00:00:51.270Z] Got response code 400; body Failed to generate manifest from function source: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './v2/auth' is not defined by "exports" in C:\Users\jhona\Desktop\proyecto-final\functions\node_modules\firebase-functions\package.json

Error: Functions codebase could not be analyzed successfully. It may have a syntax or runtime error

Activity

  1. mbleigh commented on Jul 12, 2025

    @mbleigh
    Contributor

    Hi @jhonjazzbass just to let you know it seems that you may have accidentally leaked an OpenAI API key in your pasted log. I've edited the issue to redact it but you should rotate that key for a new one.

  2. jhonjazzbass commented on Jul 12, 2025

    @jhonjazzbass
    Author

    Yes, I realized it shortly after so I deleted the key in time, thanks for letting me know.

  3. aalej commented on Jul 14, 2025

    @aalej
    Contributor

    Hey @jhonjazzbass, thanks for sharing your debug logs and code snippets! Looking at the report, it seems like the issue may be with how you're importing methods from the firebase-functions SDK. On v1, the import is firebase-functions/v1/auth but on v2 the import is firebase-functions/v2/identity.

    Try updating your code to look something like:

    const admin = require("firebase-admin");
    
    // This is the documented import method for this SDK version
    const { onUserCreated } = require("firebase-functions/v2/identity"); // Update auth -> identity
    
    admin.initializeApp();
    
    exports.setupNewUser = onUserCreated((user) => {
        console.log(`New user created: ${user.uid}`);
        return;
    });

    Also, could you share the link to where you found the code snippet documented?

    Just to note, I don't think the onUserCreated method exists in firebase-functions/v2/identity. Are you trying to trying to create a function that triggers in response to the creation of Firebase user accounts? If so, please try using a v1 function for this since 2nd gen currently does not support these types of events. See this documentation

  4. added
    Needs: Author Feedback
    on Jul 14, 2025
  5. jhonjazzbass commented on Jul 14, 2025

    @jhonjazzbass
    Author

    Hey @aalej , I wanted to thank you for your response on my issue. You were absolutely right, the problem was the import path. Changing it to require("firebase-functions/v2/identity") fixed everything completely after days of troubleshooting. Thanks again for pointing me in the right direction!

  6. added and removed
    Needs: Author Feedback
    on Jul 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions