Build script for Node project

Hello!

I’m looking to migrate a project built on Glitch to Zeit Now. Zeit is saying that my project requires a build script to load—is this something I can find on Glitch? I found the start script node server.js in ~/package.json, but it didn’t work.

Here’s the project: https://glitch.com/edit/#!/c3

Thank you for your help!

Hmm…looking at these docs https://zeit.co/docs/v2/build-step/ it seems like they require a build step which will output your app into the public directory – but looking at your app, I think it might not need a build step…? I might try adding an empty build step into the scripts section of your package.json like this:

  "scripts": {
    "start": "node server.js",
    "build": ""
  }

and see what happens??? Or if it errors saying that you have to do something, you could include an empty step like echo 'hello world' or something like that?

Well, that’s a great start! It now sucessfully builds, but just outputs a file directory containing the contents of /public, but not /views/index.html. Are there any node build commands to specify a public output file? I couldn’t find any info regarding this elsewhere.

Oh that’s very interesting. My interpretation of the views / public structure here is that, usually, the views directory would contain templates which were filled in and served from server-side code (or, I suppose, even just plain html files which were served from the server file) so they wouldn’t need to be in the public file. But if you want them to be accessible from the browser, without any server actions, I think you could just move them in and then adjust any paths pointing to them accordingly…?

Thanks! It’s now successfully outputting (example here), but the server-side code doesn’t appear to be working. If you try entering a URL such as https://example.com/index.html, nothing happens on the page, but it shows a 404 in the browser network panel coming from /processURL. It works on the Glitch-generated page http://c3.glitch.me/, but not on my own service.

Hm, interesting! I’ll take a look later. It might be something specific to Zeit (or I might have just missed something when I thought it through!)
Edit: I don’t know what your Zeit setup looks like, but have you set up something like this? It looks like Zeit might need you to specify your routes! https://zeit.co/docs/v2/advanced/routes