amireh / happypack

Happiness in the form of faster webpack build times.
MIT License
4.23k stars 124 forks source link

Cannot complete npm install of happypack repo #248

Closed oculus42 closed 5 years ago

oculus42 commented 5 years ago

Hey! This is a great tool. It does indeed make the other developers at work happy. :smile:

I pulled the repo down and attempted to poke around, but am stopped by an error on npm install. Can you provide any direction on what I might do to get the install/prepublish actions working?

I've tried to document my process thoroughly enough to follow. Working on macOS 10.13.6.

> happypack@5.0.0 test:webpack1 /Users/me/git/happypack
> NODE_PATH='./packages:./upstream/webpack1/node_modules' mocha --opts .mocha

internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module 'sinon'

So I installed sinon, and it asked for chai. Then invariant, and fs-extra, at which point it ran... and complained that sinon has deprecated sandbox.create(), and then failed 13 tests with:

 TypeError: stub(obj, 'meth', fn) has been removed, see documentation
      at stub (node_modules/sinon/lib/sinon/stub.js:25:15)
      at Sandbox.stub (node_modules/sinon/lib/sinon/sandbox.js:291:33)
      at Context.<anonymous> (lib/__tests__/applyLoaders.test.js:67:13)

I backed through the Sinon versions until I got to sinon@2.4.1 which ran...but threw an error.

[webpack@2 cache-loader] STARTING Thu Dec 20 17:39:39 EST 2018
...
[webpack@2 cache-loader]    [0] /Users/me/git/happypack/examples/cache-loader/lib/a.js 1.45 kB {0} [built] [failed] [1 error]
[webpack@2 cache-loader] 
[webpack@2 cache-loader] ERROR in /Users/me/git/happypack/examples/cache-loader/lib/a.js
[webpack@2 cache-loader] Module build failed: Error: Couldn't find preset "es2015" relative to directory "/Users/me/git/happypack/examples/cache-loader/lib"

That was on Node 10.8.0. I backed up to 8.9.4, then 6.11.5, just in case. All failed the same way.

I tried a couple of adjustments to examples/cache-loader/versions/2/package.json but to no avail.

Any thoughts?

amireh commented 5 years ago

Hey! This is a great tool. It does indeed make the other developers at work happy. 😄

😁 I'm glad to hear!

Unfortunately, getting the development environment is a little messy, never got around to automating that. You will need to npm install in a few places for it to work (look at travis.yml for an idea). A monstrous invocation like this should do it:

npm install --ignore-scripts &&
(cd upstream/webpack1; npm install) &&
(cd upstream/webpack2; npm install) &&
(cd upstream/webpack3; npm install) &&
(cd upstream/webpack4; npm install) &&
(cd packages/@happypack/example-utils; npm install --ignore-scripts) &&
(cd packages/@happypack/test-utils; npm install --ignore-scripts) &&
(cd packages/@happypack/webpack-config-composer; npm install --ignore-scripts)

I just tried it on a fresh clone of the project and it worked. If you're curious:

Let me know if there's anything else!

oculus42 commented 5 years ago

Thanks for the quick response! I'm still getting the error, even after a git reset HEAD --hard && git clean -fdx to ensure I was back at the start, and running the scripts.

I'll try from another computer or two on the probability that my current system is the problem.

amireh commented 5 years ago

Hmm, strange. It may be worthwhile to re-clone the repository altogether, since you've installed some npm packages locally (and git clean won't reach those.)

Can you show me the commands you're using & the output?

oculus42 commented 5 years ago

git clean -fdx will remove the node_modules folders as well, but I started fresh on another Mac (macOS 10.14.2, node 10.3.0, npm 6.1.0).

I cloned, ran the install script you provided, then npm run test:examples and it still fails the same way. Attached is the output of the failing webpack@2 cache-loader test.

happy-cache-loader-error.txt

I will try a PC, next.

oculus42 commented 5 years ago

Minor progress update: PC, even with git-bash.exe, was a failure. It can't handle the scripts. I haven't gone as far as installing cygwin, but I can give that a try if you think it's worth it. I'm going back to my Mac, today and giving it another try.

amireh commented 5 years ago

It's a legit issue -- let me push up a patch tonight along with some documentation

amireh commented 5 years ago

@oculus42 see #250 when you can and let me know if it fixes it for you

oculus42 commented 5 years ago

That works!

I did experience a timeout error during npm run test:coverage for webpack 4.6.0, but I think that was just a side-effect of the corporate AV going crazy about all the new node_modules folders. It was fine after a re-run.

You might also consider moving to the prepublishOnly script, to avoid errors on an initial npm install. It would require using npm 4+ for publishing, though. I found an article that might help: Safely Migrating Away From "prepublish" with npm 4

amireh commented 5 years ago

I did experience a timeout error during npm run test:coverage for webpack 4.6.0, but I think that was just a side-effect of the corporate AV going crazy about all the new node_modules folders. It was fine after a re-run.

😁 funny, I've had exactly the same thing a few months ago.

You might also consider moving to the prepublishOnly script, to avoid errors on an initial npm install.

Good call, will look into it. Thanks for the contributions and the troubleshooting!