Firebase Error: Specified "public" directory "out" does not exist, can't deploy hosting to site
Asked by Saurabh Chandravanshi:

Cannot deploy next js project to firebase, specified out folder in public directory of firebase.json, running next build \&\& next export command, next export create out folder for prod files, in local out folder is generated and working file in bitbucket out folder is not found exen after prod build.

DEBUG: Starting new HTTPS connection (1): [bitbucket.org:443](http://bitbucket.org:443/)  
DEBUG: [https://bitbucket.org:443](https://bitbucket.org/) "GET /bitbucketpipelines/official-pipes/raw/master/pipes.prod.json HTTP/1.1" 200 None  
INFO: Executing the pipe...  
/main.py:60: DeprecationWarning: FIREBASE_TOKEN is deprecated due to its legacy. For better auth use google service account KEY_FILE  
warnings.warn("FIREBASE_TOKEN is deprecated due to its legacy. "  
INFO: Current NodeJS version:  
installed : v16.15.0 (with npm 8.5.5)  
INFO: Starting deployment of the project to Firebase.  
[2022-05-26T11:10:34.369Z] > 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](https://www.googleapis.com/auth/cloudplatformprojects.readonly%22,%22https://www.googleapis.com/auth/firebase%22,%22https://www.googleapis.com/auth/cloud-platform)"]  
[2022-05-26T11:10:34.369Z] > authorizing via --token option  
[2022-05-26T11:10:34.370Z] [iam] checking project $PROJECT_ID for permissions ["firebase.projects.get","firebasehosting.sites.update"]  
[2022-05-26T11:10:34.371Z] > refreshing access token with scopes: []  
[2022-05-26T11:10:34.371Z] >>> HTTP REQUEST POST <https://www.googleapis.com/oauth2/v3/token>  
<request body omitted>  
[2022-05-26T11:10:34.445Z] <<< HTTP RESPONSE 200 {"expires":"Mon, 01 Jan 1990 00:00:00 GMT","cache-control":"no-cache, no-store, max-age=0, must-revalidate","pragma":"no-cache","date":"Thu, 26 May 2022 11:10:34 GMT","content-type":"application/json; charset=utf-8","vary":"X-Origin, Referer, Origin,Accept-Encoding","server":"scaffolding on HTTPServer2","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","alt-svc":"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","accept-ranges":"none","transfer-encoding":"chunked"}  
[2022-05-26T11:10:34.448Z] >>> [apiv2][query] POST <https://cloudresourcemanager.googleapis.com/v1/projects/$PROJECT_ID:testIamPermissions> [none]  
[2022-05-26T11:10:34.449Z] >>> [apiv2][body] POST <https://cloudresourcemanager.googleapis.com/v1/projects/$PROJECT_ID:testIamPermissions> {"permissions":["firebase.projects.get","firebasehosting.sites.update"]}  
[2022-05-26T11:10:34.552Z] <<< [apiv2][status] POST <https://cloudresourcemanager.googleapis.com/v1/projects/$PROJECT_ID:testIamPermissions> 200  
[2022-05-26T11:10:34.552Z] <<< [apiv2][body] POST <https://cloudresourcemanager.googleapis.com/v1/projects/$PROJECT_ID:testIamPermissions> {"permissions":["firebase.projects.get","firebasehosting.sites.update"]}  
[2022-05-26T11:10:34.555Z] >>> [apiv2][query] GET <https://firebase.googleapis.com/v1beta1/projects/$PROJECT_ID> [none]  
[2022-05-26T11:10:34.561Z] <<< [apiv2][status] GET <https://firebase-public.firebaseio.com/cli.json> 200  
[2022-05-26T11:10:34.562Z] <<< [apiv2][body] GET <https://firebase-public.firebaseio.com/cli.json> {"cloudBuildErrorAfter":1594252800000,"cloudBuildWarnAfter":1590019200000,"defaultNode10After":1594252800000,"minVersion":"3.0.5","node8DeploysDisabledAfter":1613390400000,"node8RuntimeDisabledAfter":1615809600000,"node8WarnAfter":1600128000000}  
[2022-05-26T11:10:34.780Z] <<< [apiv2][status] GET <https://firebase.googleapis.com/v1beta1/projects/$PROJECT_ID> 200  
[2022-05-26T11:10:34.780Z] <<< [apiv2][body] GET <https://firebase.googleapis.com/v1beta1/projects/$PROJECT_ID> {"projectId":"$PROJECT_ID","projectNumber":"860654096693","displayName":"Whatslink","name":"projects/$PROJECT_ID","resources":{"hostingSite":"$PROJECT_ID","realtimeDatabaseInstance":"$PROJECT_ID-default-rtdb","storageBucket":"$PROJECT_ID.appspot.com","locationId":"us-central"},"state":"ACTIVE"}  
=== Deploying to '$PROJECT_ID'...  
i deploying hosting  
[2022-05-26T11:10:34.786Z] >>> [apiv2][query] GET <https://firebase.googleapis.com/v1beta1/projects/$PROJECT_ID> [none]  
[2022-05-26T11:10:34.947Z] <<< [apiv2][status] GET <https://firebase.googleapis.com/v1beta1/projects/$PROJECT_ID> 200  
[2022-05-26T11:10:34.947Z] <<< [apiv2][body] GET <https://firebase.googleapis.com/v1beta1/projects/$PROJECT_ID> {"projectId":"$PROJECT_ID","projectNumber":"860654096693","displayName":"Whatslink","name":"projects/$PROJECT_ID","resources":{"hostingSite":"$PROJECT_ID","realtimeDatabaseInstance":"$PROJECT_ID-default-rtdb","storageBucket":"$PROJECT_ID.appspot.com","locationId":"us-central"},"state":"ACTIVE"}  
Error: Specified "public" directory "out" does not exist, can't deploy hosting to site "whatslink"  
? Deployment failed.  
Build Output  
+ umask 000

+ GIT_LFS_SKIP_SMUDGE=1 retry 6 git clone --branch="master" --depth 50 https://x-token-auth:$REPOSITORY_OAUTH_ACCESS_TOKEN@bitbucket.org/$BITBUCKET_REPO_FULL_NAME.git $BUILD_DIR  
Cloning into '/opt/atlassian/pipelines/agent/build'...

+ git reset --hard 701fc85b2c586a1d9ea793f4f40c10ca4b6f69dd  
HEAD is now at 701fc85 modify <https://bitbucket.org/whatslink/next_whatslink/src/701fc85b2c586a1d9ea793f4f40c10ca4b6f69dd/firebase.json> and pipeline config

+ git config user.name bitbucket-pipelines

+ git config user.email commits-noreply@bitbucket.org

+ git config push.default current

+ git config http.${BITBUCKET_GIT_HTTP_ORIGIN}.proxy <http://localhost:29418/>

+ git remote set-url origin <http://bitbucket.org/$BITBUCKET_REPO_FULL_NAME>

+ git reflog expire --expire=all --all

+ echo ".bitbucket/pipelines/generated" \>\> .git/info/exclude

+ chmod 777 $BUILD_DIR

Images used:  
build : docker.io/atlassian/default-image@sha256:edf4bd880adf9e7f7677094f7a1d944524c7f98e939550bc152523c5cf6080ff  
+ npm install  
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but <https://bitbucket.org/whatslink/next_whatslink/src/701fc85b2c586a1d9ea793f4f40c10ca4b6f69dd/package-lock.json> was generated for lockfileVersion@2. I'll try to do my best with it!

\> core-js@3.6.5 postinstall /opt/atlassian/pipelines/agent/build/node_modules/core-js  
\> node -e "try{require('./postinstall')}catch(e){}"

<br />

\> protobufjs@6.11.3 postinstall /opt/atlassian/pipelines/agent/build/node_modules/protobufjs  
\> node scripts/postinstall

<br />

\> nodemon@2.0.15 postinstall /opt/atlassian/pipelines/agent/build/node_modules/nodemon  
\> node bin/postinstall \|\| exit 0

npm WARN whatslink@1.0.0 No description  
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):  
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})  
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [@Next](/t5/user/viewprofilepage/user-id/3790307)/swc-win32-x64-msvc@12.1.5 (node_modules/@next/swc-win32-x64-msvc):  
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [@Next](/t5/user/viewprofilepage/user-id/3790307)/swc-win32-x64-msvc@12.1.5: wanted {"os":"win32","arch":"x64"} (current: {"os":"linux","arch":"x64"})  
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [@Next](/t5/user/viewprofilepage/user-id/3790307)/swc-win32-ia32-msvc@12.1.5 (node_modules/@next/swc-win32-ia32-msvc):  
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [@Next](/t5/user/viewprofilepage/user-id/3790307)/swc-win32-ia32-msvc@12.1.5: wanted {"os":"win32","arch":"ia32"} (current: {"os":"linux","arch":"x64"})  
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [@Next](/t5/user/viewprofilepage/user-id/3790307)/swc-win32-arm64-msvc@12.1.5 (node_modules/@next/swc-win32-arm64-msvc):  
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [@Next](/t5/user/viewprofilepage/user-id/3790307)/swc-win32-arm64-msvc@12.1.5: wanted {"os":"win32","arch":"arm64"} (current: {"os":"linux","arch":"x64"})  
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [@Next](/t5/user/viewprofilepage/user-id/3790307)/swc-linux-arm64-musl@12.1.5 (node_modules/@next/swc-linux-arm64-musl):  
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [@Next](/t5/user/viewprofilepage/user-id/3790307)/swc-linux-arm64-musl@12.1.5: wanted {"os":"linux","arch":"arm64"} (current: {"os":"linux","arch":"x64"})  
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [@Next](/t5/user/viewprofilepage/user-id/3790307)/swc-linux-arm64-gnu@12.1.5 (node_modules/@next/swc-linux-arm64-gnu):  
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [@Next](/t5/user/viewprofilepage/user-id/3790307)/swc-linux-arm64-gnu@12.1.5: wanted {"os":"linux","arch":"arm64"} (current: {"os":"linux","arch":"x64"})  
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [@Next](/t5/user/viewprofilepage/user-id/3790307)/swc-linux-arm-gnueabihf@12.1.5 (node_modules/@next/swc-linux-arm-gnueabihf):  
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [@Next](/t5/user/viewprofilepage/user-id/3790307)/swc-linux-arm-gnueabihf@12.1.5: wanted {"os":"linux","arch":"arm"} (current: {"os":"linux","arch":"x64"})  
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [@Next](/t5/user/viewprofilepage/user-id/3790307)/swc-darwin-x64@12.1.5 (node_modules/@next/swc-darwin-x64):  
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [@Next](/t5/user/viewprofilepage/user-id/3790307)/swc-darwin-x64@12.1.5: wanted {"os":"darwin","arch":"x64"} (current: {"os":"linux","arch":"x64"})  
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [@Next](/t5/user/viewprofilepage/user-id/3790307)/swc-darwin-arm64@12.1.5 (node_modules/@next/swc-darwin-arm64):  
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [@Next](/t5/user/viewprofilepage/user-id/3790307)/swc-darwin-arm64@12.1.5: wanted {"os":"darwin","arch":"arm64"} (current: {"os":"linux","arch":"x64"})  
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [@Next](/t5/user/viewprofilepage/user-id/3790307)/swc-android-arm64@12.1.5 (node_modules/@next/swc-android-arm64):  
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [@Next](/t5/user/viewprofilepage/user-id/3790307)/swc-android-arm64@12.1.5: wanted {"os":"android","arch":"arm64"} (current: {"os":"linux","arch":"x64"})  
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [@Next](/t5/user/viewprofilepage/user-id/3790307)/swc-android-arm-eabi@12.1.5 (node_modules/@next/swc-android-arm-eabi):  
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [@Next](/t5/user/viewprofilepage/user-id/3790307)/swc-android-arm-eabi@12.1.5: wanted {"os":"android","arch":"arm"} (current: {"os":"linux","arch":"x64"})

added 579 packages from 321 contributors and audited 590 packages in 21.687s

76 packages are looking for funding  
run \`npm fund\` for details

found 0 vulnerabilities

<br />

+ npm run out

\> whatslink@1.0.0 out /opt/atlassian/pipelines/agent/build  
\> next build \&\& next export

warn - Detected next.config.js, no exported configuration found. <https://nextjs.org/docs/messages/empty-configuration>  
warn - No build cache found. Please configure build caching for faster rebuilds. Read more: <https://nextjs.org/docs/messages/no-cache>  
Attention: Next.js now collects completely anonymous telemetry regarding usage.  
This information is used to shape Next.js' roadmap and prioritize features.  
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:  
<https://nextjs.org/telemetry>

info - Checking validity of types...  
warn - No ESLint configuration detected. Run next lint to begin setup  
info - Creating an optimized production build...  
info - Compiled successfully  
info - Collecting page data...  
Warning: You have opted-out of Automatic Static Optimization due to \`getInitialProps\` in \`pages/_app\`. This does not opt-out pages with \`getStaticProps\`  
Read more: <https://nextjs.org/docs/messages/opt-out-auto-static-optimization>

Page Size First Load JS  
? ? / 1.41 kB 177 kB  
? /_app 0 B 163 kB  
? ? /404 1.8 kB 178 kB  
? ? /dashboard 952 B 177 kB  
? ? /mobile-app 2.54 kB 178 kB  
? ? /open-chat 15.3 kB 191 kB  
? ? css/29dd92ea5b35c4bf.css 2.85 kB  
? ? /Policies/PrivacyPolicy 2.86 kB 179 kB  
? ? /Policies/Terms 3 kB 179 kB  
? ? /saved-links 665 B 176 kB  
? ? /short-links 664 B 176 kB  
+ First Load JS shared by all 163 kB  
? chunks/framework-5f4595e5518b5600.js 42 kB  
? chunks/main-779b41245c009d2a.js 28.3 kB  
? chunks/pages/_app-d7a8b6b489fa8365.js 91.3 kB  
? chunks/webpack-9b312e20a4e32339.js 836 B  
? css/9473410fd58606b5.css 13.3 kB

? (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)

warn - Detected next.config.js, no exported configuration found. <https://nextjs.org/docs/messages/empty-configuration>  
info - using build directory: /opt/atlassian/pipelines/agent/build/.next  
info - Copying "static build" directory  
info - No "exportPathMap" found in "/opt/atlassian/pipelines/agent/build/next.config.js". Generating map from "./pages"  
info - Launching 7 workers  
info - Exporting (0/9)  
info - Copying "public" directory  
info - Exporting (2/9)  
info - Exporting (4/9)  
info - Exporting (6/9)  
info - Exporting (9/9)  
Export successful. Files written to /opt/atlassian/pipelines/agent/build/out  
Searching for files matching artifact pattern build/\*\*

Searching for test report files in directories named \[test-results, failsafe-reports, test-reports, TestResults, surefire-reports\] down to a depth of 4  
Finished scanning for test reports. Found 0 test report files.  
Merged test suites, total number tests is 0, with 0 failures and 0 errors.


Answers:
author: o_kyrdan
body: Hi [@Saurabh Chandravanshi](/t5/user/viewprofilepage/user-id/4946977)

Thank you for your question!

It would be nice if you provide us with details config bitbucket-pipelines.yml file.

Best regards,  
Oleksandr Kyrdan

comments: author: Saurabh Chandravanshi
body: image: atlassian/default-image:3

pipelines:  
branches:  
master:  
- parallel:  
- step:  
name: 'Build'  
script:  
- npm install  
- npm run out # this means next build \&\& next export  
artifacts:  
- build/\*\*  
- step:  
name: 'Deployment to Production'  
deployment: production  
script:  
- pipe: atlassian/firebase-deploy:2.0.0  
variables:  
FIREBASE_TOKEN: $FIREBASE_TOKEN  
PROJECT_ID: $PROJECT_ID  
MESSAGE: 'Deploying \<Project\>'  
EXTRA_ARGS: '--only hosting:\<Project\>'  
DEBUG: 'true'


author: Saurabh Chandravanshi
body: Hey [@o_kyrdan](/t5/user/viewprofilepage/user-id/2862136) can you help here


author: Petrus Hakakoski
body: You are running the export step along the deployment, which can't have the file since it's not made before the steps.

Make them run one by one and not parallel


Tags: bitbucket-cloud

cloud

firebase