firebase / firebase/firebase-tools

Make hosting emulator/deploy work even if the command was executed from outside of the hosting directory

Open
#5,903 5 comments 0 reactions 0 assignees View on GitHub
integration: web frameworks type: bug
Dominant language
TypeScript
Stars
4.5k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
84

Description

### [REQUIRED] Environment info

**firebase-tools:** 12.2.0, 12.2.1

**Platform:** MacOS

### [REQUIRED] Test case

Create a new NextJs app:

```
npx create-next-app@latest
```
Initialize a firebase app in the parent directory and configure it to use nextjs for hosting.

`hosting.source` in your `firebase.json` should point to the nextjs app like this `"source": "./my-app"`

Start hosting emulator running `firebase emulators:start` from outside of the nextjs directory.

### [REQUIRED] Steps to reproduce

See above.

### [REQUIRED] Expected behavior

Nextjs app starts inside hosting emulator.

### [REQUIRED] Actual behavior

App crashes because it can't resolve paths.

```
Server Error
ModuleBuildError: Module build failed (from ./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js):
TypeError: Cannot read properties of undefined (reading 'config')
at getTailwindConfig (/Users/zuzel/Projects/hs/apps/new-web/node_modules/tailwindcss/lib/lib/setupTrackingContext.js:87:62)
at /Users/zuzel/Projects/hs/apps/new-web/node_modules/tailwindcss/lib/lib/setupTrackingContext.js:99:92
at /Users/zuzel/Projects/hs/apps/new-web/node_modules/tailwindcss/lib/processTailwindFeatures.js:48:11
at plugins (/Users/zuzel/Projects/hs/apps/new-web/node_modules/tailwindcss/lib/plugin.js:38:63)
at LazyResult.runOnRoot (/Users/zuzel/Projects/hs/apps/new-web/node_modules/next/node_modules/postcss/lib/lazy-result.js:339:16)
at LazyResult.runAsync (/Users/zuzel/Projects/hs/apps/new-web/node_modules/next/node_modules/postcss/lib/lazy-result.js:393:26)
at LazyResult.async (/Users/zuzel/Projects/hs/apps/new-web/node_modules/next/node_modules/postcss/lib/lazy-result.js:221:30)
at LazyResult.then (/Users/zuzel/Projects/hs/apps/new-web/node_modules/next/node_modules/postcss/lib/lazy-result.js:206:17)

This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
getTailwindConfig
/Users/zuzel/Projects/hs/apps/new-web/node_modules/tailwindcss/lib/lib/setupTrackingContext.js (87:62)

/Users/zuzel/Projects/hs/apps/new-web/node_modules/tailwindcss/lib/lib/setupTrackingContext.js (99:92)

/Users/zuzel/Projects/hs/apps/new-web/node_modules/tailwindcss/lib/processTailwindFeatures.js (48:11)
plugins
/Users/zuzel/Projects/hs/apps/new-web/node_modules/tailwindcss/lib/plugin.js (38:63)
LazyResult.runOnRoot
/Users/zuzel/Projects/hs/apps/new-web/node_modules/next/node_modules/postcss/lib/lazy-result.js (339:16)
LazyResult.runAsync
/Users/zuzel/Projects/hs/apps/new-web/node_modules/next/node_modules/postcss/lib/lazy-result.js (393:26)
LazyResult.async
/Users/zuzel/Projects/hs/apps/new-web/node_modules/next/node_modules/postcss/lib/lazy-result.js (221:30)
LazyResult.then
/Users/zuzel/Projects/hs/apps/new-web/node_modules/next/node_modules/postcss/lib/lazy-result.js (206:17)
getTailwindConfig
file:///Users/zuzel/Projects/hs/apps/new-web/node_modules/tailwindcss/lib/lib/setupTrackingContext.js (87:62)

file:///Users/zuzel/Projects/hs/apps/new-web/node_modules/tailwindcss/lib/lib/setupTrackingContext.js (99:92)

file:///Users/zuzel/Projects/hs/apps/new-web/node_modules/tailwindcss/lib/processTailwindFeatures.js (48:11)
plugins
file:///Users/zuzel/Projects/hs/apps/new-web/node_modules/tailwindcss/lib/plugin.js (38:63)
LazyResult.runOnRoot
file:///Users/zuzel/Projects/hs/apps/new-web/node_modules/next/node_modules/postcss/lib/lazy-result.js (339:16)
LazyResult.runAsync
file:///Users/zuzel/Projects/hs/apps/new-web/node_modules/next/node_modules/postcss/lib/lazy-result.js (393:26)
LazyResult.async
file:///Users/zuzel/Projects/hs/apps/new-web/node_modules/next/node_modules/postcss/lib/lazy-result.js (221:30)
LazyResult.then
file:///Users/zuzel/Projects/hs/apps/new-web/node_modules/next/node_modules/postcss/lib/lazy-result.js (206:17)
processResult
file:///Users/zuzel/Projects/hs/apps/new-web/node_modules/next/dist/compiled/webpack/bundle5.js (28:394802)

file:///Users/zuzel/Projects/hs/apps/new-web/node_modules/next/dist/compiled/webpack/bundle5.js (28:396519)

file:///Users/zuzel/Projects/hs/apps/new-web/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js (1:8645)

file:///Users/zuzel/Projects/hs/apps/new-web/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js (1:5828)
r.callback
file:///Users/zuzel/Projects/hs/apps/new-web/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js (1:4039)

file:///Users/zuzel/Projects/hs/apps/new-web/node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js (113:37)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.