attestation-deplacement-derogatoire-q4-2020: Heroku deployment error

En essayant de déployer mon fork sur heroku, j’ai eu cette erreur:

👷 parcel-plugin-sw-cache: sw-cache: Service worker generation failed Error: There was an issue using one of the provided 'templatedURLs'. 'index.html' from '{"./":["index.html"]}':
Error: One of the glob patterns doesn't match any files. Please remove or fix the following: {
  "globDirectory": "/tmp/build_8e305657_/dist",
  "globPattern": "index.html",
  "globIgnores": [
    "**/node_modules/**/*",
    "**/sw.js"
  ]
}
    at /tmp/build_8e305657_/node_modules/workbox-build/build/lib/get-file-manifest-entries.js:104:21
    at Array.reduce (<anonymous>)
    at /tmp/build_8e305657_/node_modules/workbox-build/build/lib/get-file-manifest-entries.js:91:40
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/tmp/build_8e305657_/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next (/tmp/build_8e305657_/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
    at /tmp/build_8e305657_/node_modules/@babel/runtime/helpers/asyncToGenerator.js:32:7
    at new Promise (<anonymous>)
    at /tmp/build_8e305657_/node_modules/@babel/runtime/helpers/asyncToGenerator.js:21:12
    at /tmp/build_8e305657_/node_modules/workbox-build/build/lib/get-file-manifest-entries.js:130:17

Suivie d’autres. Une idée de comment je pourrais régler le problème ? Voici le log complet.

-----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       NODE_VERBOSE=false
       
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 12.x...
       Downloading and installing node 12.19.0...
       Using default npm version: 6.14.8
       
-----> Installing dependencies
       Installing node modules
       
       > @fortawesome/fontawesome-common-types@0.2.32 postinstall /tmp/build_8e305657_/node_modules/@fortawesome/fontawesome-common-types
       > node attribution.js
       
       Font Awesome Free 0.2.32 by @fontawesome - https://fontawesome.com
       License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
       
       
       > @fortawesome/free-solid-svg-icons@5.15.1 postinstall /tmp/build_8e305657_/node_modules/@fortawesome/free-solid-svg-icons
       > node attribution.js
       
       Font Awesome Free 5.15.1 by @fontawesome - https://fontawesome.com
       License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
       
       
       > @fortawesome/fontawesome-svg-core@1.2.32 postinstall /tmp/build_8e305657_/node_modules/@fortawesome/fontawesome-svg-core
       > node attribution.js
       
       Font Awesome Free 1.2.32 by @fontawesome - https://fontawesome.com
       License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
       
       
       > puppeteer@1.20.0 install /tmp/build_8e305657_/node_modules/puppeteer
       > node install.js
       
       
       
       > core-js@2.6.11 postinstall /tmp/build_8e305657_/node_modules/core-js
       > node -e "try{require('./postinstall')}catch(e){}"
       
       
       > deasync@0.1.20 install /tmp/build_8e305657_/node_modules/deasync
       > node ./build.js
       
       `linux-x64-node-12` exists; testing
       Binary is fine; exiting
       
       > fsevents@1.2.13 install /tmp/build_8e305657_/node_modules/@parcel/watcher/node_modules/fsevents
       > node install.js
       
       
       Skipping 'fsevents' build as platform linux is not supported
       
       > parcel-bundler@1.12.4 postinstall /tmp/build_8e305657_/node_modules/parcel-bundler
       > node -e "console.log('\u001b[35m\u001b[1mLove Parcel? You can now donate to our open collective:\u001b[22m\u001b[39m\n > \u001b[34mhttps://opencollective.com/parcel/donate\u001b[0m')"
       
       Love Parcel? You can now donate to our open collective:
        > https://opencollective.com/parcel/donate
       added 1251 packages in 27.66s
       
-----> Build
       Running build
       
       > attestation-derogatoire-de-deplacement@1.0.5 prebuild /tmp/build_8e305657_
       > run-p lint clean:dist
       
       
       > attestation-derogatoire-de-deplacement@1.0.5 lint /tmp/build_8e305657_
       > eslint src/**/*.js
       
       
       > attestation-derogatoire-de-deplacement@1.0.5 clean:dist /tmp/build_8e305657_
       > rimraf dist
       
       
       > attestation-derogatoire-de-deplacement@1.0.5 build /tmp/build_8e305657_
       > cross-env npm run build:simple
       
       
       > attestation-derogatoire-de-deplacement@1.0.5 build:simple /tmp/build_8e305657_
       > cross-env-shell VERSION=$npm_package_version parcel build --public-url $PUBLIC_URL ./src/index.html ./src/robots.txt ./src/sitemap.xml
       
lscpu: failed to determine number of CPUs: /sys/devices/system/cpu/possible: No such file or directory
       ✨  Built in 1.01s.
       
       dist/sitemap.xml    886 B    770ms
       dist/robots.txt      74 B    770ms
👷 parcel-plugin-sw-cache: sw-cache: Service worker generation failed Error: There was an issue using one of the provided 'templatedURLs'. 'index.html' from '{"./":["index.html"]}':
Error: One of the glob patterns doesn't match any files. Please remove or fix the following: {
  "globDirectory": "/tmp/build_8e305657_/dist",
  "globPattern": "index.html",
  "globIgnores": [
    "**/node_modules/**/*",
    "**/sw.js"
  ]
}
    at /tmp/build_8e305657_/node_modules/workbox-build/build/lib/get-file-manifest-entries.js:104:21
    at Array.reduce (<anonymous>)
    at /tmp/build_8e305657_/node_modules/workbox-build/build/lib/get-file-manifest-entries.js:91:40
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/tmp/build_8e305657_/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next (/tmp/build_8e305657_/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
    at /tmp/build_8e305657_/node_modules/@babel/runtime/helpers/asyncToGenerator.js:32:7
    at new Promise (<anonymous>)
    at /tmp/build_8e305657_/node_modules/@babel/runtime/helpers/asyncToGenerator.js:21:12
    at /tmp/build_8e305657_/node_modules/workbox-build/build/lib/get-file-manifest-entries.js:130:17
       
       > attestation-derogatoire-de-deplacement@1.0.5 postbuild /tmp/build_8e305657_
       > cross-env-shell react-snap
       
events.js:291
      throw er; // Unhandled 'error' event
      ^
Error: ENOENT: no such file or directory, open '/tmp/build_8e305657_/dist/index.html'
Emitted 'error' event on ReadStream instance at:
    at internal/fs/streams.js:136:12
    at FSReqCallback.oncomplete (fs.js:156:23) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/tmp/build_8e305657_/dist/index.html'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! attestation-derogatoire-de-deplacement@1.0.5 postbuild: `cross-env-shell react-snap`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the attestation-derogatoire-de-deplacement@1.0.5 postbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npmcache.ZnZp5/_logs/2020-11-01T14_34_58_325Z-debug.log
-----> 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

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16

Most upvoted comments

D’où venait le problème exactement ?

J’ai pris ton package.json ainsi que ton Procfile, j’ai déplacé tout les devDependencies dans les Dependencies car elles sont purgées après chaque build et devant chaque commandes parcel j’ai ajouté l’argument npx afin de pouvoir charger les modules depuis un dossier externe je crois. Je débute sur Node.js, j’ai utilisé la documentation mais tout à l’air de fonctionner.

Pour que ce soit plus propre, il faudrait ne pas toucher aux devDependencies et aux Dependencies mais changer la config d’Heroku telle que : NPM_CONFIG_PRODUCTION=false, comme ça les packages Dev ne sont pas supprimés après chaque build.

M’enfin voilà ça fonctionne, si je peux vous être utile n’hésitez pas 😃

Problème résolu de mon côté. Tout fonctionne sur Heroku, merci à tous. Je push tout ça et je vous envoie le repo.

EDIT : Repo Heroku Friendly

Si vous cherchez à déployer, lors du build, comme il a été dit, il faut ajouter la variable d’environnement PUBLIC_URL et la mettre (a priori, pour la plupart d’entre vous) à '/'.

Bon finalement j’ai réussi à faire un déploiement sur Heroku en ajoutant un fichier procfile à la racine : web: npm run start

Et en changeant mon package.json :

{
  "name": "attestation-derogatoire-de-deplacement",
  "version": "1.0.5",
  "description": "Générateur d'attestation de déplacement dérogatoire'",
  "main": "certificate.js",
  "engines": {
    "node": "10.15.2"
  },
  "scripts": {
    "lint": "eslint src/**/*.js",
    "preformat": "prettier --write \"src/**/*.js\"",
    "format": "npm run lint -- --fix",
    "start": "parcel ./src/index.html",
    "start:grid": "cross-env VERSION=localversion parcel ./src/grid.html",
    "clean:dist": "rimraf dist",
    "prebuild": "run-p lint clean:dist",
    "build:simple": "cross-env-shell VERSION=$npm_package_version parcel build --public-url $PUBLIC_URL ./src/index.html ./src/robots.txt ./src/sitemap.xml",
    "postbuild": "cross-env-shell",
    "prebuild:ci": "run-p lint clean:dist",
    "build:ci": "cross-env npm run build:simple",
    "postbuild:ci": "cross-env-shell",
    "build:dev": "cross-env PUBLIC_URL='/' npm run build:simple",
    "preserve": "npm run build",
    "serve": "serve dist",
    "serve:dist": "serve dist",
    "build": "parcel src/index.html -- open",
    "heroku-prebuild": "",
    "heroku-postbuild": "parcel build src/index.html"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/lab-mi/attestation-deplacement-derogatoire-q4-2020"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/lab-mi/attestation-deplacement-derogatoire-q4-2020/issues"
  },
  "devDependencies": {
    "@babel/core": "^7.12.3",
    "@babel/plugin-transform-runtime": "^7.12.1",
    "babel-eslint": "^10.1.0",
    "copy-and-watch": "^0.1.5",
    "cross-env": "^7.0.2",
    "eslint": "^7.12.1",
    "eslint-config-standard": "^16.0.0",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-promise": "^4.2.1",
    "eslint-plugin-standard": "^4.0.2",
    "npm-run-all": "^4.1.5",
    "parcel-bundler": "^1.12.4",
    "parcel-plugin-sw-cache": "^0.3.1",
    "postcss-current-selector": "0.0.3",
    "postcss-nested": "^4.2.3",
    "postcss-nested-ancestors": "^2.0.0",
    "postcss-preset-env": "^6.7.0",
    "posthtml-expressions": "^1.6.0",
    "prettier": "^2.1.2",
    "react-snap": "^1.23.0",
    "rimraf": "^3.0.2",
    "serve": "^11.3.2"
  },
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.32",
    "@fortawesome/free-solid-svg-icons": "^5.15.1",
    "bootstrap": "^4.5.3",
    "parcel": "^1.12.4",
    "pdf-lib": "^1.11.2",
    "qrcode": "^1.4.4"
  },
  "browserslist": [
    "last 5 versions"
  ],
  "reactSnap": {
    "source": "dist",
    "minifyHtml": {
      "collapseWhitespace": false,
      "removeComments": false
    },
    "puppeteerArgs": [
      "--no-sandbox",
      "--disable-setuid-sandbox"
    ]
  },
  "cache": {
    "globPatterns": [
      "**/*.{html,js,css,jpg,png,pdf,svg,eot,ttf,woff,woff2}"
    ],
    "disablePlugin": false,
    "inDev": true,
    "strategy": "default",
    "clearDist": false,
    "templatedURLs": {
      "./": [
        "index.html"
      ]
    }
  }
}

A noter les étapes build, heroku-prebuild et heroku-postbuild

@a2br Je pense que l’erreur vient de la variable d’environnement PUBLIC_URL qui est manquante dans ta conf (cf discussion dans #80)

@a2br et @jeremyzaire , si ça peut vous inspirer pour vos conf heroku, voici la mienne pour Google App Engine (actuellement je build en local puis je deploy sur l’instance mais dans le principe, je pense que je pourrais faire le build côté serveur). a6146be50ab06dbd2669b20b01631bf590be0644

Ajout d’un script de build au package.json où j’ai une url définie par défaut que je peux changer si besoin en variable d’environnement. (Pour VERSION, faut ignorer, c’est juste un restant de l’attestation couvre-feu. Maintenant la version semble récupérée depuis ce qui a été défini dans le package.json) :

    "gcloud:build": "npm run clean:dist && cross-env-shell NODE_PATH=. PUBLIC_URL=\"${PUBLIC_URL:-https://autocovid19.oa.r.appspot.com/}\" VERSION=\"${VERSION:-testversion}\" npm run build:simple"

(source)

Ensuite j’ai une conf Google App qui définie à quel endroit il faut servir les fichiers statiques qui ont été générés :

runtime: nodejs12

env_variables:
  PUBLIC_URL: "https://autocovid19.oa.r.appspot.com/"
  VERSION: "1.0.6-rc1 (tar-gezed x theblackhole)"

handlers:
  - url: /
    static_files: dist/index.html
    upload: dist/index.html

  - url: /(.*)
    static_files: dist/\1
    upload: dist/(.*)

(source)

Cool, bon à savoir 😃