Skip to content

Deployment fails with ERR_PACKAGE_PATH_NOT_EXPORTED on v2/params despite correct firebase-functions v6+ dependency #9085

@gcamargo39-coder

Description

@gcamargo39-coder

[REQUIRED] Environment info

firebase-tools: 14.15.1

Platform: Windows

[REQUIRED] Test case
The issue occurs with a minimal setup using ES Modules and a v2 function that imports from firebase-functions/v2/params.

functions/package.json

JSON

{
"name": "functions",
"main": "index.js",
"type": "module",
"engines": {
"node": "20"
},
"dependencies": {
"firebase-admin": "^12.1.0",
"firebase-functions": "^6.4.0"
}
}
functions/index.js

JavaScript

import { onCall } from "firebase-functions/v2/https";
import { defineSecret } from "firebase-functions/v2/params";
import * as logger from "firebase-functions/logger";

// This secret is used to test the import that is failing.
const testSecret = defineSecret("TEST_SECRET");

export const testFunction = onCall({ secrets: [testSecret] }, (request) => {
logger.info("Test function was called successfully!");
return { message: "The test function worked!" };
});
[REQUIRED] Steps to reproduce
Create a new project folder and initialize a Firebase project with functions: firebase init functions.

Choose JavaScript as the language and select the option to use ES Modules (this will add "type": "module" to package.json).

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

Navigate into the functions directory and run npm install.

Navigate back to the project root directory.

Attempt to deploy the function using the command: firebase deploy --only functions.

[REQUIRED] Expected behavior
The function should be analyzed and deployed successfully to the Firebase project without any errors.

[REQUIRED] Actual behavior
The deployment fails during the source code analysis phase. The command output shows an ERR_PACKAGE_PATH_NOT_EXPORTED error, indicating that the subpath ./v2/params cannot be found within the firebase-functions module, even though the specified version (^6.4.0) should contain it.

The error log is as follows:

Error: Functions codebase could not be analyzed successfully. It may have a syntax or runtime error
...
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './v2/params' is not defined by "exports" in C:\sinapsy-final\functions\node_modules\firebase-functions\package.json imported from C:\sinapsy-final\functions\index.js
at new NodeError (node:internal/errors:405:5)
at exportsNotFound (node:internal/modules/esm/resolve:259:10)
at packageExportsResolve (node:internal/modules/esm/resolve:589:9)
at packageResolve (node:internal/modules/esm/resolve:764:14)
at moduleResolve (node:internal/modules/esm/resolve:830:20)
at defaultResolve (node:internal/modules/esm/resolve:1035:11)
at DefaultModuleLoader.resolve (node:internal/modules/esm/loader:269:12)
at DefaultModuleLoader.getModuleJob (node:internal/modules/esm/loader:153:32)
at ModuleWrap. (node:internal/modules/esm/module_job:76:33)
at link (node:internal/modules/esm/module_job:75:36) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
This issue has been extensively troubleshooted, including:

Deleting node_modules and package-lock.json and reinstalling.

Clearing the npm cache with npm cache clean --force.

Recreating the project from scratch in a new directory.

Confirming the contents of package.json on disk via terminal commands.

The error persists in both the local emulator and when deploying to the live Firebase environment.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions