parcel-bundler / parcel

The zero configuration build tool for the web. 📦🚀
https://parceljs.org
MIT License
43.32k stars 2.25k forks source link

Building - lscpu: failed to determine number of CPUs - Heroku #133

Closed albinotonnina closed 6 years ago

albinotonnina commented 6 years ago

🐛/🙋 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.
reel commented 6 years ago

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

albinotonnina commented 6 years ago

@reel Please do!

DeMoorJasper commented 6 years ago

has been fixed in #142

obedm503 commented 5 years ago

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

karltaylor commented 5 years ago

I'm having this same problem but on App Engine on Google Cloud Platform, using middleware to bundle through Express.

amankapoor commented 5 years ago

I got this issue just now when creating a docker image from node 8.10.0 alpine. (parcel 1.9.7) Although, it doesn't stop the bundling, but I don't see the progress for that npm command after this error.

askesis commented 5 years ago

I have a similar problem with 1.9.7

karltaylor commented 5 years ago

Any update on this? I can try and recreate tonight and see the error from GCP App Engine

gabriofr commented 5 years ago

Anything? v1.9.7 on Heroku: lscpu: failed to determine number of CPUs: /sys/devices/system/cpu/possible: No such file or directory

co2-git commented 5 years ago

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

jessehattabaugh commented 5 years ago

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`
JakeCooper commented 5 years ago

Getting the same error as @gabsinator on Parcel 1.11.0.

Tried adding PARCEL_WORKERS=1 and now parcel build hangs indefinitely, but seems to work locally.

cyrilchapon commented 5 years ago

Please reopen. This issue is not fixed.

gmfc commented 5 years ago

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
JakeCooper commented 5 years ago

This is an error that seems to occur with the node-sass package. Try installing dart-sass instead; they're idempotent.

At least, that was the issue for myself and a couple other people.

elgelbo commented 5 years ago

Try clearing build cache using heroku-repo

I had the same repository deployed on an existing and fresh heroku app -- the older one with history of deploy was not loading client-side js, new one was.

Cleared it out of existing, and voila.

cedeber commented 5 years ago

None of the solutions work.

okowl commented 4 years ago

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.

simarmannsingh commented 3 years ago

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...