1

I'm running fastify on node.js and using Caddy server for reverse proxying localhost to a domain (authsvc.dev) that serves up an index.html file in this UI project.

All was running fine until a couple days ago. Now, when I run npm run ui I get the following error messages in the console. The index.html file is not being served up. The src/public/index.html file exists and was working a couple days ago, but maybe some issue with npx serve {{path-to-file}}? Please help!

ERROR: Not able to read /{{path-to-proj}}/ui/src/public/index.html/serve.json: ENOTDIR: not a directory, open '/{{path-to-proj}}/ui/src/public/index.html/serve.json'
npx serve src/public/index.html exited with code 1

Not sure where or why index.html/serve.json is trying to be read and how to go about fixing it.

I'm running macOs Big Sur v11.6

Some things I've tried.

  1. Deleting node_modules and npm install
  2. Deleting package-lock.json and npm install
  3. updating to latest npm
  4. Changing to different version of node (now on v14.15.1)
  5. Clearing npm cache rm -rf ~/.npm npm clear cache
  6. npx serve src/public/ -- allows me to see when I'm at localhost:5000, but not authsvc.dev

I do have Caddy running with a reverse proxy set up.

{
  local_certs
}

authsvc.dev {
  reverse_proxy 127.0.0.1:5000
}

api.authsvc.dev {
  reverse_proxy 127.0.0.1:4000
}

Host file

127.0.0.1 authsvc.dev
127.0.0.1 api.authsvc.dev

package.json scripts

  "scripts": {
    "all": "concurrently \"npm run server\" \"cd ../ui\" \"npm run ui\"",
    "server": "cd ../api && npm run start",
    "ui": "concurrently \"nodemon src/index.js\" \"npx serve src/public/index.html\"",
    "ui1": "nodemon src/index.js",
    "ui2": "npx serve src/public/",
    "caddy": "caddy run",
    "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watchAll"
  },
  "dependencies": {
    "colors": "^1.4.0",
    "concurrently": "^6.2.2",
    "cross-fetch": "^3.1.4",
    "dotenv": "^10.0.0",
    "fastify": "^3.22.0",
    "fastify-static": "^4.2.3"
  }

results of npm run all

briang
  • 91
  • 10

1 Answers1

0

Serve should not take an .html file but the folder containing your entire website.
You can try this command : serve src/public/, without the npx prefix and normally it should work

mvetois
  • 111
  • 11
  • I’ll give it another try, but I think I tried that too without success, but I’ll give it another go when I get to my computer. Thanks! – briang Oct 04 '21 at 14:24
  • Still not working for me, but I updated some additional details above. Maybe I was missing some details that could be helpful troubleshooting the issue. – briang Oct 04 '21 at 15:54