jakejs / jake

JavaScript build tool, similar to Make or Rake. Built to work with Node.js.
http://jakejs.com
Apache License 2.0
1.97k stars 190 forks source link

`Cannot read property 'apply' of undefined` with v10.4.1 #368

Closed esamattis closed 4 years ago

esamattis commented 4 years ago

Upgraded from 10.3.2 to 10.4.1 and started getting this:

/xxx/node_modules/jake/bin/cli.js:31
jake.run.apply(jake, args);
         ^

TypeError: Cannot read property 'apply' of undefined
    at Object.<anonymous> (/xxx/node_modules/jake/bin/cli.js:31:10)

btw, is there a changelog for these changes? Could not find anything from changelog.md or the releases page.

mde commented 4 years ago

10.4.x was supposed to be a transparent refactor, with no functional changes.

We do have an extensive battery of tests, with everything passing before this release. Could you provide me your Jakefile, or a repo I can use to repro the problem?

esamattis commented 4 years ago

Yeah, of course. Sorry about not including it earlier.

The jakefile content:

const { task } = require("jake");

task("test", () => {
    console.log("test");
});

Repro steps:

git clone https://github.com/esamattis/jake-bug.git
cd jake-bug/
npm ci
./node_modules/.bin/jake test
mde commented 4 years ago

Thanks so much for reporting this. It turned out to be a problem with packaging and distribution, not source code — which explains why none of the tests caught it.

I've updated our tests to install the actual package locally, and run the tests using the binary in that distro, instead of using the CLI from source code. This will catch any of these issues with packaging and distribution in the future. I also added a test for this specific bug.

This is fixed in v10.4.3, also on NPM.