Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS Docker build error: Error: Cannot find module '../' #2333

Closed
jshimko opened this issue May 23, 2017 · 9 comments
Closed

macOS Docker build error: Error: Cannot find module '../' #2333

jshimko opened this issue May 23, 2017 · 9 comments
Assignees
Labels
verified reproducible For issues that describe bugs that the core team was able to confirm

Comments

@jshimko
Copy link
Contributor

jshimko commented May 23, 2017

Several people (including myself) have been consistently seeing this when trying to build the default Reaction image on macOS. I believe this is a result of changes that Meteor released to fix the last macOS/Docker file system nightmare that took 6 months to clear up.

The original Meteor/Docker build issue was (meteor/meteor#8491), but after my PR was merged, they realized that it caused a new one (meteor/meteor#8569) that was related to the way Windows handles symlinks. So a bunch of changes were made to several core file system methods that are used in the meteor build command in that second PR. The missing module errors below started happening for me immediately after that release.

All of Meteor's file system handling methods are defined here, so I'm pretty sure that's where the fix will end up being.

As with most core Meteor issues, I just have no idea where to start to troubleshoot it. Supporting all major file systems is hard. You fix one problem and then another pops up on a different OS as a result.

[-] Running npm install in the server bundle...


> [email protected] install /opt/reaction/dist/bundle/programs/server/node_modules/fibers
> node build.js || nodejs build.js

`linux-x64-46` exists; testing
Binary is fine; exiting

> [email protected] install /opt/reaction/dist/bundle/programs/server
> node npm-rebuild.js


> [email protected] install /opt/reaction/dist/bundle/programs/server/npm/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build

module.js:327
    throw err;
    ^

Error: Cannot find module '../'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/opt/reaction/dist/bundle/programs/server/npm/node_modules/.bin/node-pre-gyp:15:20)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bcrypt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs bcrypt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls bcrypt
npm ERR! There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.meteor/packages/meteor-tool/.1.4.4_2.5g3s0q++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/.npm/_logs/2017-05-23T10_38_29_888Z-debug.log
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node npm-rebuild.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node npm-rebuild.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the meteor-dev-bundle package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node npm-rebuild.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs meteor-dev-bundle
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls meteor-dev-bundle
npm ERR! There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.meteor/packages/meteor-tool/.1.4.4_2.5g3s0q++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/.npm/_logs/2017-05-23T10_38_29_936Z-debug.log
The command '/bin/sh -c cd $APP_SOURCE_DIR &&             bash $BUILD_SCRIPTS_DIR/build-meteor.sh &&             bash $BUILD_SCRIPTS_DIR/post-build-cleanup.sh' returned a non-zero code: 1
@jshimko jshimko added bug For issues that describe a defect or regression in the released software verified reproducible For issues that describe bugs that the core team was able to confirm meteor and removed bug For issues that describe a defect or regression in the released software labels May 23, 2017
@nonfungibletunji
Copy link

any update on the situation, cause i have been working to get this resolved for over five days

@jshimko
Copy link
Contributor Author

jshimko commented Jun 23, 2017

Unfortunately, no news yet. You should be able to build on any other operating system, so there are workarounds until this is resolved. Building on CircleCI or a remote machine managed with Docker Machine are my two current recommendations. Reaction already has a working CircleCI config that you can customize.

If you don't need build automation from CircleCI, you could just use Docker Machine to start a build server whenever you need it. It only takes about 2 minutes for a new server to be ready. You can start the server, do a build on it, push it to Docker Hub, and then shut down the server. You can use a really powerful server with tons of resources and it'll barely cost anything.

Start a server
see Docker Machine docs for available options
also see detail/price chart for EC2 instances

# Digital Ocean
# https://docs.docker.com/machine/drivers/digital-ocean/

docker-machine create \
  --driver digitalocean \
  --digitalocean-access-token <your API key> \
  --digitalocean-size 8gb \
  builder

# or...

# AWS
# https://docs.docker.com/machine/drivers/aws/

docker-machine create \
  --driver amazonec2 \
  --amazonec2-access-key <access key> \
  --amazonec2-secret-key <secret key> \
  --amazonec2-region us-east-1 \
  --amazonec2-instance-type t2.large \
  builder

Tell your local Docker to run on the remote server

eval "$(docker-machine env builder)"

Build/push your custom image

# build
docker build -t myorg/reaction:latest .

# push to Docker Hub
docker push myorg/reaction:latest

Shut the server down until you need it again

docker-machine stop builder

Start the server when you need to build again

docker-machine start builder

eval "$(docker-machine env builder)"

# do your builds...

Destroy the server when you no longer need it

docker-machine kill builder
docker-machine rm builder

Aside from the fact that this is a workaround to issues with Meteor builds on macOS, this also lets you do much faster builds on high power servers that have tons of resources and network bandwidth. And it will cost a few pennies at most.

@aaronjudd
Copy link
Contributor

aaronjudd commented Jul 18, 2017

By removing the bcrypt package and letting Meteor default back to the slower js version of bcrypt, I was able to successfully build now without the ..module error.

I am hoping the ..modules error may have been caused by the various build issues reported on the bcrypt repo, and that the build was attempting to use the failed install(?).

meteor npm remove bcrypt --save
docker build -t reactioncommerce/reaction:latest .

...

Successfully built 744f590a58a2
Successfully tagged reactioncommerce/reaction:latest

Like to see if anyone else is able to reproduce this build(success)?

@jshimko
Copy link
Contributor Author

jshimko commented Jul 18, 2017

I can confirm this fixes the build issues on macOS. And the container definitely runs/works.

I love fixes like that.

This doesn't explain why every other Meteor app isn't having the same problem, but I'll take the win!

@aaronjudd
Copy link
Contributor

Inspired by @tdmoneybanks suggestion that we remove bcrypt, once I started looking at those build errors I got suspicious as this was very similar to a closed Meteor issue for node-pre-gyp failing to build. I'd looked at this before and didn't want to remove because it leaves us with a nasty warning that life will be 3x slower (although, in practice, will it really?)...

aaronjudd pushed a commit that referenced this issue Jul 18, 2017
Resolves #2333
Apparently the failing bcrypt / fallback installation was causing
..module not found errors.
— need to evaluate for performance issues (see warning)
— need to update docs to warn about the warning..
— todo find better solution!
@jshimko
Copy link
Contributor Author

jshimko commented Jul 18, 2017

JACKPOT. Just proved it's 100% on Meteor and has nothing to do with Reaction.

Reproduction steps...

# create a fresh/empty Meteor app
meteor create docker-fail
cd docker-fail

# install bcrypt
meteor npm i -S bcrypt

# add a Dockerfile
echo "FROM jshimko/meteor-launchpad:latest" > Dockerfile

# build 
docker build -t my-test .

# FAIL
...
Error: Cannot find module '../'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/opt/meteor/dist/bundle/programs/server/npm/node_modules/.bin/node-pre-gyp:15:20)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)

Now confirm it was bcrypt for good measure...

meteor npm uninstall -S bcrypt

docker build -t my-test .

# SUCCESS!
...
Successfully built 1bded9798423
Successfully tagged my-test:latest

I'll file an issue with them in the morning.

aaronjudd pushed a commit that referenced this issue Jul 19, 2017
Resolves #2333
Apparently the failing bcrypt / fallback installation was causing
..module not found errors.
— need to evaluate for performance issues (see warning)
— need to update docs to warn about the warning..
— todo find better solution!
@nonfungibletunji
Copy link

nonfungibletunji commented Jul 19, 2017 via email

@ronaldocpontes
Copy link

Hi @jshimko

I would be very interested in following the issue tracker for bcrypt in Meteor.

Would you be able to provide us with the link?

@aaronjudd
Copy link
Contributor

@stunjiturner yes, seems to be the fix. Something else that we could try is going back a few versions of bcrypt until we find one that does work with the Meteor build. (at some point, there had to be a compatible release).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
verified reproducible For issues that describe bugs that the core team was able to confirm
Projects
None yet
Development

No branches or pull requests

4 participants