Description
[REQUIRED] Environment info
firebase-tools:
8.2.0
Platform:
macOS
Node:
10.16.0
Yarn:
2.0.0-rc.33
[REQUIRED] Test case
When generating, installing and running a fresh Typescript version of a functions project using the firebase-tools CLI tool and Yarn 2, 20 errors are produced when executing yarn serve
- 3 unique:
Cannot find module 'express-serve-static-core'.
Cannot find type definition file for 'node'.
'functions' is declared but its value is never read.
I can resolve these in the following way, but the resolution causes other errors which are not curable:
yarn add @types/node -D
yarn add @types/express-serve-static-core -D
- Modify
src/index.ts
to export thehelloWorld
function present in the comments.
This causes the following CLI output:
i Starting emulators: ["functions"]
✔ functions: Emulator started at http://localhost:5001
i functions: Watching "/Users/craig/dev/sandbox/firebase-functions-yarn-2" for Cloud Functions...
⚠ Error: Cannot find module '/Users/craig/dev/sandbox/firebase-functions-yarn-2/.yarn/cache/firebase-admin-npm-8.11.0-40c4d739ef-3.zip/node_modules/firebase-admin/package.json'
Require stack:
- /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js
Require stack:
- /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
at Function.module_1.Module._resolveFilename (/Users/craig/dev/sandbox/firebase-functions-yarn-2/.pnp.js:12283:54)
at Module._load (internal/modules/cjs/loader.js:840:27)
at Function.module_1.Module._load (/Users/craig/dev/sandbox/firebase-functions-yarn-2/.pnp.js:12160:36)
at Module.require (internal/modules/cjs/loader.js:1019:19)
at require (internal/modules/cjs/helpers.js:77:18)
at /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:123:32
at Generator.next (<anonymous>)
at fulfilled (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:4:58)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
⚠ Your function was killed because it raised an unhandled error.
I can confirm that the zip file '/Users/craig/dev/sandbox/firebase-functions-yarn-2/.yarn/cache/firebase-admin-npm-8.11.0-40c4d739ef-3.zip' contains the path 'node_modules/firebase-admin/package.json'.
I tried downgrading to firebase-tools v8.0.3 as per this issue to no avail.
I tried upgrading Yarn to use the latest sources version to no avail.
I tried using a newer version of Node (v12.16.3) to no avail.
I tried using a newer version of tslint (v6.1.2) to no avail.
Could be an issue with the PnP resolver (https://classic.yarnpkg.com/en/docs/pnp/troubleshooting)? Although I tried running the emulator using the following command, and the error still prevailed.
NODE_OPTIONS="--require ./.pnp.js" firebase emulators:start --only functions
I've created a repository containing the generated project so it's as minimal as possible: https://bitbucket.org/cjmyles/firebase-functions-yarn-2/src. I've included firebase-debug.log as well as the Yarn 2 Zero Install files.
[REQUIRED] Steps to reproduce
- Install Yarn 2.
- Execute
firebase init functions
from the CLI - choose a Firebase project; Typescript (Y); TSLint (Y); install dependencies (N). - Execute
yarn
to install dependencies. - Execute
yarn serve
to see the first set of errors.
[REQUIRED] Expected behavior
Generated project should execute without issues, same as if the project's dependencies were installed and the project executed using Yarn 1.
[REQUIRED] Actual behavior
See test case above.