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

npm postinstall uses global bower that might not exist #224

Closed
AlexClineBB opened this issue Jan 19, 2016 · 4 comments
Closed

npm postinstall uses global bower that might not exist #224

AlexClineBB opened this issue Jan 19, 2016 · 4 comments

Comments

@AlexClineBB
Copy link

While trying to dockerize lemur for running in our environment, I ran into an issue that I thought I'd document in case anyone else encounters it.

Following the installation instructions, you start up the python virtual environment and make develop. This takes a while in a docker container, but eventually will error out with this:

[19:16:07] 'build:inject' errored after 11 ms
[19:16:07] Error: Bower components directory does not exist at bower_components

I traced this to the fact that bower install fails to run during the setup phase, because package.json has this line:

"postinstall": "bower install --allow-root --config.interactive=false",

npm will use the global bower after installing the node modules and will fail (very quietly) if one doesn't exist:

npm install
npm WARN cannot run in wd Lemur@ bower install --allow-root --config.interactive=false (wd=/usr/local/src/lemur)

The way to workaround this error is to run bower install after the failure, using the local bower. I used something like this:

cd /usr/local/src/lemur && \
source /usr/local/src/lemur/bin/activate && \
make develop || \
node_modules/bower/bin/bower install --allow-root --config.interactive=false && \
make develop

If package.json is changed so the postinstall command uses the bower installation within the node_modules directory, this workaround won't be needed. Not sure if this should truly be a bug or if it's just a documentation clarification - I'll let the maintainers decide.

@kevgliss
Copy link
Contributor

Thanks for the info, I don't know a great deal how NPM but is there a way to specify local npm during runtime? You also have the option of pre-compiling the javascript. The installation script is smart enough to check for the static/dist folder and not try to re-compile it if it exists. This is actually how we deploy it, jenkins builds a deb with compiled javascript inside.

@AlexClineBB
Copy link
Author

Probably the cleanest way to use the local bower it to change the postinstall line to this:

"postinstall": "node_modules/.bin/bower install --allow-root --config.interactive=false",

As a thought exercise, do you have an example of how to pre-compile the javascript that I could use before make develop?

@kevgliss
Copy link
Contributor

Mind opening up a PR with that change? It looks good to me.

This is essentially what I do in jenkins:

npm install
node_modules/.bin/gulp --cwd $WORKSPACE/root/apps/lemur build
node_modules/.bin/gulp --cwd $WORKSPACE/root/apps/lemur package

@kevgliss
Copy link
Contributor

Closing based on #227.

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

No branches or pull requests

2 participants