parcel: Building - lscpu: failed to determine number of CPUs - Heroku

πŸ›/πŸ™‹ not sure.

My plan was to build my app on heroku and statically serve the dist folder

package.json

  "scripts": {
    "start": "parcel index.html",
    "build": "parcel build index.html --no-minify --public-url ./",
    "postinstall": "yarn build"
  }

Procfile

web: node server.js

server.js

const path = require('path')
const express = require('express')
const logfmt = require('logfmt')
const app = express()

app.use(logfmt.requestLogger())

app.use('/', express.static(path.join(__dirname + '/dist')));

app.listen(Number(process.env.PORT || 5000))

Now I’m not an expert on heroku so errors like these are not clear to me. Locally, through heroku CLI everything works. On heroku looks like that the output folder dist is not actually created. I may be doing something wrong on heroku but it could be something related to parcel and CPUs? As a result I get a 404 on heroku.

Dist folder here is in the repo hence it works: https://scrollytelling.herokuapp.com https://github.com/albinotonnina/scrollytelling

remote:        Building dependencies
remote:        Installing node modules (yarn.lock)
remote:        yarn install v1.3.2
remote:        [1/4] Resolving packages...
remote:        [2/4] Fetching packages...
---> remote:        info fsevents@1.1.3: The platform "linux" is incompatible with this module.
---> remote:        info "fsevents@1.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
remote:        [3/4] Linking dependencies...
remote:        [4/4] Building fresh packages...
remote:        $ yarn build
remote:        yarn run v1.3.2
remote:        $ parcel build index.html --no-minify --public-url ./
---> remote:        ⏳  Building...
---> remote:        
---> remote:        lscpu: failed to determine number of CPUs: /sys/devices/system/cpu/possible: No such file or directory
remote:        ⏳  Building index.html...
remote:        Done in 0.75s.
remote:        Done in 15.74s.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 19 (3 by maintainers)

Most upvoted comments

None of the solutions work.

this is still happening in version 1.9.7 and still fails to create the dist folder

Please reopen. This issue is not fixed.

@gabsinator in the meantime this is being solved, you can set the following in your Heroku config vars: PARCEL_WORKERS=1

Using Heroku, same problem

2019-02-22T15:26:00.568594+00:00 app[web.1]: > parcel build ./client/index.html

2019-02-22T15:26:00.568595+00:00 app[web.1]: 

2019-02-22T15:26:01.610727+00:00 app[web.1]: lscpu: failed to determine number of CPUs: /sys/devices/system/cpu/possible: No such file or directory

2019-02-22T15:26:23.419944+00:00 heroku[web.1]: State changed from starting to crashed

2019-02-22T15:26:23.401121+00:00 heroku[web.1]: Process exited with status 1

I’m getting a similar error from zeit/now-cli build. Could be related.

> /bin/sh: lscpu: not found
> οΏ½  No entries found.
>     at Bundler.bundle (/home/nowuser/src/node_modules/parcel-bundler/src/Bundler.js:260:17)
>     at <anonymous>
> npm ERR! code ELIFECYCLE
> npm ERR! errno 1
> npm ERR!
> npm ERR! jessehattabaugh-com@0.0.2 build: `PARCEL_WORKERS=0 npm run clean && parcel build -d public src/*.html`

I am getting this error too while deploying a Parcel built app on Heroku. Tried all the above solutions. config var PARCEL_WORKERS is set to 1

lscpu: failed to determine number of CPUs: /sys/devices/system/cpu/possible: No such file or directory

@albinotonnina : How did you fixed your issue? Could you please share your solution? Might work for someone else too…

In parcel the cpu count would be used to determine the number of workers to spawn for the build. If you still have this problem you can try to set PARCEL_WORKERS environment variable to 2 (worked for me) and the lscpu path will be omitted altogether while deploying on Heroku.

The problem is with physical-cpu-count. I can make a pull request to remove that package and use the else branch:

const os = require('os');

let amount;

const cores = os.cpus().filter(function(cpu, index) {
  const hasHyperthreading = cpu.model.includes('Intel');
  const isOdd = index % 2 === 1;
  return !hasHyperthreading || isOdd;
});
amount = cores.length;

module.exports = amount;

Could add that somewhere in there: https://github.com/parcel-bundler/parcel/blob/master/src/WorkerFarm.js#L27