Amit Shakya
Amit Shakya

Reputation: 994

how to configure "npm run-script build" command in Nodejs package.json

I am trying to deploy nextjs based project on AWS EBS, but it is not able to run script "npm run-script build" on server, by this it makes nextjs based build package folder and can run app. here my json.

 "scripts": {
    "dev": "node server.js",
    "build": "next build",
    "start": "cross-env NODE_ENV=production node server.js"
  }

when I deployed my app on server it gives following error.

Error: Could not find a valid build in the '/var/app/current/.next' directory! Try building your app with 'next build' before starting the server.

I need to run command "npm run-script build" before running app on server, but dosen't aware how to achieve this

Upvotes: 1

Views: 5121

Answers (1)

Amit Shakya
Amit Shakya

Reputation: 994

simply we can run multiple commands at a time.

"scripts": {
    "dev": "node server.js",
    "build": "next build",
    "start": "npm-run-script-build && cross-env NODE_ENV=production node server.js"
  }

Upvotes: 1

Related Questions