简体   繁体   中英

Procfile to deploy Node.js website on Heroku

I have an app and locally it works.

npm run serve

I tried deploying a node.js test app to Heroku, but getting errors. What should I write in my Procfile.

Error:

npm ERR! missing script: start

Package.json

{
    "name": "demo",
    "version": "0.1.0",
    "description": "",
    "engines": {
        "node": "14.17.0",
        "npm": "6.14.15"
    },
    "main": "index.ts",
    "scripts": {
        "build": "webpack",
        "serve": "webpack-dev-server --open",
        "serve:external": "webpack-dev-server --host 0.0.0.0"
    },
    "author": "",
    "license": "0BSD",
    "devDependencies": {
        "@getify/eslint-plugin-proper-ternary": "^3.0.1",
        "@types/file-saver": "^2.0.5",
        "node-sass": "^4.13.1",
        "sass-loader": "^8.0.2",
        "style-loader": "^1.1.3",
        "ts-loader": "^6.2.1",
        "typescript": "^3.8.3",
        "webpack": "^4.42.1",
        "webpack-cli": "^3.3.11",
        "webpack-dev-server": "^3.10.3"
    },
    "dependencies": {
        "@navvis/ivion": "file:navvis-ivion-10.3.2.tgz",
        
    }
}

So, I wrote Procfile

web: npm run serve  // I am not sure if it is OK:

Folder:

node_modules
Src
   -> Index.ts
Procfile
package.json


heroku logs --tail

2022-05-25T11:21:50.093632+00:00 heroku[web.1]: State changed from crashed to starting
2022-05-25T11:21:52.482784+00:00 heroku[web.1]: Starting process with command `npm start`
2022-05-25T11:21:54.886999+00:00 app[web.1]: npm ERR! missing script: start
2022-05-25T11:21:54.928759+00:00 app[web.1]:
2022-05-25T11:21:54.929309+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2022-05-25T11:21:54.929364+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2022-05-25T11_21_54_887Z-debug.log
2022-05-25T11:21:55.057472+00:00 heroku[web.1]: Process exited with status 1
2022-05-25T11:21:55.145992+00:00 heroku[web.1]: State changed from starting to crashed


2022-05-25T11:35:40.173569+00:00 heroku[web.1]: State changed from crashed to starting
2022-05-25T11:35:42.669473+00:00 heroku[web.1]: Starting process with command `npm start`
2022-05-25T11:35:44.000000+00:00 app[api]: Build succeeded
2022-05-25T11:35:45.246831+00:00 app[web.1]: npm ERR! missing script: start

Make sure the Procfile looks like:

web: npm start

If you are using git; remember to add, commit and push your changes.

If it doesn't work, try this solution here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM