question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failing build with NITRO_PRESET=firebase

See original GitHub issue

Environment

  • Operating System: Darwin
  • Node Version: v16.11.0
  • Nuxt Version: 3-3.0.0-27234133.44f8904
  • Package Manager: Yarn
  • Bundler: Webpack
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Describe the bug and expected behavior

Attempting to build the starter project and following the Firebase-specific instructions fails with the following error (full stack trace below):

 ERROR  Package subpath './package.json' is not defined by "exports" in /Users/username/code/project/myapp-nuxt3/node_modules/firebase-functions/package.json

Steps to reproduce

  1. Follow the instructions on https://v3.nuxtjs.org/docs/deployment/firebase
  2. Try to build with NITRO_PRESET=firebase yarn build (same results with NITRO_PRESET=firebase npm run build)

Additional context

$ ~/c/s/myapp-nuxt3> NITRO_PRESET=firebase yarn build

yarn run v1.22.10
$ nuxt build
Nuxt CLI v3.0.0-27234133.44f8904                                                                 16:58:28
✔ Generated nuxt.d.ts                                                                            16:58:28
ℹ Vite warmed up in 698ms                                                                        16:58:29
ℹ Client built in 1110ms                                                                         16:58:30
ℹ Building server...                                                                             16:58:30
✔ Server built in 564ms                                                                          16:58:30
ℹ Nitro preset is firebase                                                                       16:58:30
ℹ Cleaning up .output                                                                            16:58:30
start Generating public...                                                                       16:58:30
✔ Generated public .output/public                                                                16:58:30
start Building server...                                                                         16:58:30
start Writing server bundle...                                                                   16:58:47
✔ Server built                                                                                   16:58:53
  ├─ .output/server/index.mjs (383 B) (175 B gzip)
  ├─ .output/server/chunks/nitro/firebase.mjs (8.64 MB) (1.27 MB gzip)
  ├─ .output/server/chunks/index.mjs (390 kB) (90.1 kB gzip)
  ├─ .output/server/chunks/app/vue3.mjs (588 B) (279 B gzip)
  ├─ .output/server/chunks/app/server.mjs (141 kB) (35.3 kB gzip)
  ├─ .output/server/chunks/app/render.mjs (24.3 kB) (6.71 kB gzip)
  └─ .output/server/chunks/app/client.manifest.mjs (224 B) (157 B gzip)
Σ Total size: 9.19 MB (1.41 MB gzip)

 ERROR  Package subpath './package.json' is not defined by "exports" in /Users/username/code/project/myapp-nuxt3/node_modules/firebase-functions/package.json

  at new NodeError (node:internal/errors:371:5)
  at throwExportsNotFound (node:internal/modules/esm/resolve:440:9)
  at packageExportsResolve (node:internal/modules/esm/resolve:692:3)
  at resolveExports (node:internal/modules/cjs/loader:482:36)
  at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
  at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
  at Function.Module._load (node:internal/modules/cjs/loader:778:27)
  at Module.require (node:internal/modules/cjs/loader:1005:19)
  at require (node:internal/modules/cjs/helpers:102:18)
  at writeRoutes$1 (node_modules/@nuxt/nitro/dist/index.mjs:1384:29)

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
AncientAzemcommented, Oct 12, 2021

I was going to open a new issue but saw this one and I am now getting a different error but on the same command for build to firebase. See below for the bug report (I can open a new ticket if needed):

Environment

  • Operating System: Linux
  • Node Version: v14.18.1 (also occurs with v16.11.1)
  • Nuxt Version: 3-3.0.0-27234503.d5127e9
  • Package Manager: Yarn
  • Bundler: Webpack
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Describe the bug and expected behavior

Upon following the instructions at https://v3.nuxtjs.org/docs/deployment/firebase for deploying to firebase via Nitro, an error occurs after the server is built. It appears the cli is trying to build the firebase functions package but is looking for the package.json in the wrong directory.

/home/devjinnial/projects/baldesion-archive/node_modules/firebase-functions/lib/index.js/firebase-functions/package.json: ENOTDIR: not a directory, open '/home/devjinnial/projects/baldesionarchive/node_modules/firebase-functions/lib/index.js/firebase-functions/package.json'

Steps to reproduce

  1. Create new project with nuxi: npx nuxi init nuxt3-app
  2. Install packages with yarn
  3. Create .firebaserc with project id from firebase (see https://v3.nuxtjs.org/docs/deployment/firebase)
  4. Add the firebase packages: yarn add --dev firebase-admin firebase-functions firebase-functions-test
  5. Login to Firebase (I was already logged in)
  6. Run NITRO_PRESET=firebase yarn build

Additional context

Here is the full output from my console:

devjinnial@DESKTOP-6ER3HFL:~/projects/baldesion-archive$ NITRO_PRESET=firebase yarn build
yarn run v1.22.15
$ nuxt build
Nuxt CLI v3.0.0-27234503.d5127e9                                                                                                                                                                                                                        17:17:21
✔ Generated nuxt.d.ts                                                                                                                                                                                                                                   17:17:21
ℹ Vite warmed up in 883ms                                                                                                                                                                                                                               17:17:22
ℹ Client built in 1383ms                                                                                                                                                                                                                                17:17:23
ℹ Building server...                                                                                                                                                                                                                                    17:17:23
✔ Server built in 647ms                                                                                                                                                                                                                                 17:17:23
ℹ Nitro preset is firebase                                                                                                                                                                                                                              17:17:23
ℹ Cleaning up .output                                                                                                                                                                                                                                   17:17:23
start Generating public...                                                                                                                                                                                                                              17:17:23
✔ Generated public .output/public                                                                                                                                                                                                                       17:17:23
start Building server...                                                                                                                                                                                                                                17:17:23
start Writing server bundle...                                                                                                                                                                                                                          17:17:50
✔ Server built                                                                                                                                                                                                                                          17:17:56
  ├─ .output/server/index.mjs (383 B) (175 B gzip)
  ├─ .output/server/chunks/nitro/firebase.mjs (8.64 MB) (1.27 MB gzip)
  ├─ .output/server/chunks/index.mjs (390 kB) (90.1 kB gzip)
  ├─ .output/server/chunks/app/vue3.mjs (588 B) (279 B gzip)
  ├─ .output/server/chunks/app/server.mjs (142 kB) (35.3 kB gzip)
  ├─ .output/server/chunks/app/render.mjs (24.3 kB) (6.72 kB gzip)
  └─ .output/server/chunks/app/client.manifest.mjs (224 B) (157 B gzip)
Σ Total size: 9.19 MB (1.41 MB gzip)

 ERROR  /home/devjinnial/projects/baldesion-archive/node_modules/firebase-functions/lib/index.js/firebase-functions/package.json: ENOTDIR: not a directory, open '/home/devjinnial/projects/baldesion-archive/node_modules/firebase-functions/lib/index.js/firebas
e-functions/package.json'

  at Object.openSync (fs.js:497:3)
  at Object.readFileSync (fs.js:393:35)
  at Object.readFileSync (node_modules/jsonfile/index.js:50:22)
  at readPackageJson (node_modules/@nuxt/nitro/dist/index.mjs:171:18)
  at writeRoutes$1 (node_modules/@nuxt/nitro/dist/index.mjs:1395:29)
  at runMicrotasks (<anonymous>)
  at processTicksAndRejections (internal/process/task_queues.js:95:5)
  at async nitro:compiled (node_modules/@nuxt/nitro/dist/index.mjs:1343:7)
  at async _build (node_modules/@nuxt/nitro/dist/index.mjs:1066:3)
  at async node_modules/nuxt3/dist/index.mjs:753:7

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

1reaction
ekwuscommented, Oct 25, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found