"Error: No such directory" Did you forget › to run a build? after netlify deploy --prod

I am having an issue in finalising the deployment after netlify deploy --prod. I tried to run npm run build but it doesn’t work.
Then it suggest to do this:
Please provide a publish directory (e.g. “public” or “dist” or “.”):
I tried the 3 options, the third one went through and what I get is a black rotten app:

Hiya, @oosp :wave:

Welecome to the Netlify Forums! Sorry you are having trouble with your deploy.

This Support Guide contains a ton of useful debugging tips that can likely help you solve your problem :slight_smile: Additionally, this Support Guide houses all of our resources for debugging build and deploy issues.

We also recommend trying to search the forums with the build error you encountered - it’s likely your question was already asked by someone else!

If you are still having problems, please provide as much information as you can on what you have already tried, including:

  1. the error message you are receiving
  2. your full deploy log
  3. what your build settings are
  4. your package.json, .toml file, etc.

Thanks!

1 Like

Hello Hillary! My saviour! :slight_smile: I will try to be as much precise as I can. There is no trace of this error in the blog unfortunately.
The error appears at the final stage of my deployment when I do the command netlify deploy --prod and it asks me for a publish directory and I type build. I tried also “public”, “dist” and “.” as well, no success.

1)This is the error:


(➜  portfolio-frontend git:(main) netlify deploy --prod
Please provide a publish directory (e.g. "public" or "dist" or "."):
/Users/oosp/development/portfolio/portfolio-frontend
? Publish directory /Users/oosp/development/portfolio/portfolio-frontend/build 
Deploy path: /Users/oosp/development/portfolio/portfolio-frontend/build 
 ›   Error: No such directory /Users/oosp/development/portfolio/portfolio-frontend/build ! Did you forget 
 ›   to run a build?
  1. The last full deploy logs are these:
    6:02:41 PM: Creating deploy upload records
    6:03:21 PM: Starting post processing
    6:03:21 PM: Post processing - HTML
    6:03:22 PM: Post processing - header rules
    6:03:22 PM: Post processing - redirect rules
    6:03:22 PM: Post processing done
    6:03:25 PM: Site is live :sparkles:

This one is showing a black screen and it’s the last one I tried, this one is the result of choosing “.” as a publish directory.

  1. 6:01:13 PM: Canceling deploy

This one is the one that appears when I type build as a publish directory

  1. I can’t see the build setting if these indications are correct: Site settings > Build & deploy > Continuous Deployment > Build settings . Please let me know if the latter is not correct. I don’t see any .toml file

4)my package.json:

{
  "name": "portfolio-frontend",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.3",
    "@testing-library/react": "^12.1.4",
    "@testing-library/user-event": "^13.5.0",
    "devicon": "^2.15.1",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-router-dom": "^6.2.2",
    "react-scripts": "5.0.0",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Thank you very much!

Hey @oosp,

Since you’re deploying via CLI, there’s no way for us to check what’s happening locally. Would it be possible for you to share the repo?

Hello @hrishikesh! Thank you very much for replying to me!
Of course!

This is my repo: https://github.com/ornellaspada/portfolio-

I look forward to receiving any update from you! Thank you again! :slight_smile:

Dear @hrishikesh,
I solved the issue, which was that I had to run again the npm run build before doing the re-deployment. Thanks!

Thank you so much for coming back and confirming! This will be beneficial to future forums members who encounter something similar.

Happy building :rocket: