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

In chroot environments, npm run build fails #337

@vielhuber

Description

@vielhuber

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions