Problem z deployem appki na heroku przy użyciu parcela

0

Siemka,

ostatnio deployowałem 2 appki zrobione w React i nie było żadnego problemu. Dzisiaj robiliśmy w ramach studiów nowy projekt z wykorzystaniem parcela i analogicznie jak resztę chciałem go zdeployować na Heroku :) Sam deploy zakończył się sukcesem, lecz po przejściu na zdeployowaną stronkę otrzymuję komunikat:

Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
heroku logs --tail

Link: https://spa-shop-application.herokuapp.com/

mój package.json:

{
    "name": "it-spa",
    "version": "1.0.0",
    "description": "",
    "main": "it-spa.js",
    "scripts": {
        "start:db": "json-server --watch database.json",
        "start:app": "parcel ./index.html --open"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "dependencies": {
        "@parcel/transformer-sass": "^2.2.1",
        "json-server": "^0.15.1",
        "parcel": "^2.2.1",
        "sass": "^1.49.0",
        "bootstrap": "^5.1.3",
        "jquery": "^3.6.0"
    }
}
0

Dawno nie korzystałem z parcela, ani z heroku, więc mogę się mylić, ale żeby zbudować wersje produkcyjną aplikacji to heroku potrzebuje polecenia build w pliku package.json (https://devcenter.heroku.com/articles/nodejs-support#customizing-the-build-process).

Wtedy heroku odpali polecenie npm run build, parcel wygeneruje odpowiednie pliki do katalogu (dist lub build) i heroku uruchomi swój serwer na odpowiednim adresie.

Powinno być chyba coś takiego

{
  "scripts": {
       "build": "parcel build ./index.html",
       "start:db": "json-server --watch database.json",
       "start:app": "parcel ./index.html --open"
   },
}
0

@Xarviel: Gdy dodałem linijke z build to na heroku wywaliło mi błąd

Chociaż na innej appce node.js nie mam "build" tylko "test" i "start" i appka na heroku działa...

-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/nodejs
-----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 16.x...
       Downloading and installing node 16.14.0...
       Using default npm version: 8.3.1
       
-----> Restoring cache
       - node_modules
       
-----> Installing dependencies
       Installing node modules
       
       added 766 packages, and audited 767 packages in 38s
       
       145 packages are looking for funding
         run `npm fund` for details
       
       12 moderate severity vulnerabilities
       
       To address issues that do not require attention, run:
         npm audit fix
       
       To address all issues (including breaking changes), run:
         npm audit fix --force
       
       Run `npm audit` for details.
       
-----> Build
       Running build
       
       > [email protected] build
       > parcel build ./index.html
       
       Building...
       Bundling...
       🚨 Build failed.
       
@parcel/namer-default: Target "main" declares an output file path of "it-spa.js"
which does not match the compiled bundle type "html".
       
  /tmp/build_77be2993/package.json:5:13
    4 |     "description": "",
  > 5 |     "main": "it-spa.js",
  >   |             ^^^^^^^^^^^ Did you mean "it-spa.html"?
    6 |     "scripts": {
    7 |         "build": "parcel build ./index.html",
       
         💡 Try changing the file extension of "main" in package.json.
       
-----> Build failed
       
       We're sorry this build is failing! You can troubleshoot common issues here:
       https://devcenter.heroku.com/articles/troubleshooting-node-deploys
       
       Some possible problems:
       
       - Node version not specified in package.json
         https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
       
       Love,
       Heroku
       
 !     Push rejected, failed to compile Node.js app.
 !     Push failed
1

@Xarviel: Dobra udało mi się rozwiązać problem :)
usunąłem

"main": "it-spa.js",

z Jsona, dodałem build i zdeployowałem appke na netlify i poszło:)

1 użytkowników online, w tym zalogowanych: 0, gości: 1