Skip to content
This repository was archived by the owner on Dec 5, 2019. It is now read-only.

In chroot environments, npm run build fails #337

Closed
vielhuber opened this issue Aug 8, 2018 · 2 comments
Closed

In chroot environments, npm run build fails #337

vielhuber opened this issue Aug 8, 2018 · 2 comments

Comments

@vielhuber
Copy link

In a chroot environment, where /proc etc. is not available, require('os').cpus() returns undefined.

If we run "npm run build" on a Vue.js project, we get the following error:

Building for production.../xxx/node_modules/uglifyjs-webpack-plugin/dist/uglify/index.js:54
    this.maxConcurrentWorkers = parallel === true ? _os2.default.cpus().length - 1 : Math.min(Number(parallel) || 0, _os2.default.cpus().length - 1);
                                                                       ^

TypeError: Cannot read property 'length' of undefined

If we change the line 19 of Runner.js from

this.maxConcurrentWorkers = parallel === true ? os.cpus().length - 1 : Math.min(Number(parallel) || 0, os.cpus().length - 1);

to

this.maxConcurrentWorkers = parallel === true ? (os.cpus() !== undefined ? os.cpus().length : 1) - 1 : Math.min(Number(parallel) || 0, (os.cpus() !== undefined ? os.cpus().length : 1) - 1);

it works.

There is only another error in vue-cli (where again some kind of cpu function is used without checking if it returns undefined), but I will open up another support ticket there.

Can you please improve this line of code?

@alexander-akait
Copy link
Member

@vielhuber PR welcome, also please put comment on issue in source code

@vielhuber
Copy link
Author

See: #338

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants