how to write build script command for Node Js project

Viewed 38

my friends, I am a beginner and I am trying to build my project that was built with Node, but I don't know the build script. I searched for it a lot but I didn't find a solution. Thank you

package.json

{
  "name": "server",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "engines":{
    "node":"16.x"
  } ,
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node server.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bcryptjs": "^2.4.3",
    "cookie-parser": "^1.4.6",
    "dotenv": "^16.0.2",
    "express": "^4.18.1",
    "jsonwebtoken": "^8.5.1",
    "mongoose": "^6.5.4",
    "nodemon": "^2.0.19"
  }
}
1 Answers

I would say the error you are getting is the same as described in Missing Build Scripts (Errors - Vercel Docs).

Apparently, you get this error message when you have a package.json file located in the root directory of your project, but you have no api directory and no vercel.json configuration.

They recommend to set your package.json file to something similar to this:

{
  "scripts": {
    "build": "[my-framework] build --output public"
  }
}

However, for now it is not possible to have a server-run Node.js web app hosted directly with Vercel.

Vercel is a cloud platform for static frontends and serverless functions.

In order to deploy a Node.js API with Vercel you would need to use their serverless functions or use the Node.js helpers.

Related