GithubHelp home page GithubHelp logo

Comments (21)

dleavitt avatar dleavitt commented on May 5, 2024 2

Nice! okay for @gauravtiwari to close this ticket?

from webpacker.

ytbryan avatar ytbryan commented on May 5, 2024 1

@sealocal Rails 5.0.1

@gauravtiwari https://github.com/ytbryan/webpacker-demos

gonna be away for the next two days, will look at all these info and dig into it when i'm back.

from webpacker.

gauravtiwari avatar gauravtiwari commented on May 5, 2024 1

@ytbryan this works - https://webpacker-vue.herokuapp.com/ and code here - https://github.com/gauravtiwari/webpacker-vue

The only additions are - adding correct buildpacks for heroku

heroku buildpacks:set heroku/nodejs --index 1
heroku buildpacks:set heroku/ruby --index 2

And add a Procfile to run webpack dev server + configuration in development.rb

and moving all the devDependencies except webpack dev server to dependencies block. Strangely, yarn doesn't seem to install them on production. There are many issues filed on Github in same regards, here is one - yarnpkg/yarn#2739

from webpacker.

gauravtiwari avatar gauravtiwari commented on May 5, 2024 1

@ytbryan Deployed updated version here - https://webpacker-demos-vue.herokuapp.com/ and made PR for you - ytbryan/webpacker-demos#1

screen shot 2017-02-25 at 05 19 01

from webpacker.

gauravtiwari avatar gauravtiwari commented on May 5, 2024 1

@sealocal everything moved to root folder so, now it's usual setup for yarn. #101

from webpacker.

sealocal avatar sealocal commented on May 5, 2024

Which version of Rails are you using?

from webpacker.

gauravtiwari avatar gauravtiwari commented on May 5, 2024

@ytbryan Do you have the repo somewhere on github? You generally don't need to do assets:precompile, there is a hook that does that when rails run assets:precompile on production.

# Compile packs after we've compiled all other assets during precompilation

I will try your steps and see if I can reproduce it. Mostly likely it's related to Rails version you have used.

from webpacker.

sealocal avatar sealocal commented on May 5, 2024

From the error log above:

remote: sh: 1: ./node_modules/webpack/bin/webpack.js: not found

I suspect that yarn is not globally available - I've been running into this same problem, but when deploying to Amazon Linux.

Using webpacker 1.0 with Rails 5.0, that hook executes, but webpack.js is not installed because yarn install did not successfully install the node_modules (again, because yarn is not available) so the assets fail to precompile.

I hope that makes sense!

from webpacker.

gauravtiwari avatar gauravtiwari commented on May 5, 2024

Thanks @ytbryan. @sealocal Yes I get the same error that webpack isn't found. If we use node buildpack for heroku it does detects yarn and run yarn install by default, which I can see in the log that it installs all dependencies but not the one listed in devDependencies, that's why it can't find webpack.

screen shot 2017-02-25 at 04 48 15

from webpacker.

gauravtiwari avatar gauravtiwari commented on May 5, 2024

@sealocal This explains more - https://yarnpkg.com/lang/en/docs/cli/install/#toc-yarn-install-production so, perhaps by default the gem installer should list those modules, which will be used in production should be under dependencies by default.

from webpacker.

sealocal avatar sealocal commented on May 5, 2024

You're right. I haven't tried deploying my app to Heroku - so I can see that you're saying Heroku installed only the production dependencies.

However, my problem is slightly different. On Beanstalk, yarn is not available to install on Amazon Linux Ruby. I've installed it manually, but would prefer to check for the binary and install upon deploy.

I'm using Beanstalk's Ruby platform:

 64bit Amazon Linux 2016.09 v2.3.1 running Ruby 2.3 (Puma)

I can open another issue for discussion around Beanstalk deployment.

from webpacker.

gauravtiwari avatar gauravtiwari commented on May 5, 2024

@sealocal You can use .ebextensions as pre deploy hook to setup yarn for linux using this guide - https://yarnpkg.com/en/docs/install/#linux-tab ? As an example (not sure it works though),

#  Create a file .ebextensions/yarn.config
# Runs right before `npm install` in '.../50npm.sh'
"/opt/elasticbeanstalk/hooks/appdeploy/pre/49yarn.sh" :
    mode: "000775"
    owner: root
    group: users
    content: |
        #!/bin/bash
        app="/tmp/deployment/application";

        # install yarn
        wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo;
        curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -;
        yum -y install yarn;

        # Install deps
        cd "${app}";
        yarn --production;

Resource: http://www.eq8.eu/blogs/29-aws-elasticbeanstalk-deployment-hooks

from webpacker.

sealocal avatar sealocal commented on May 5, 2024

Heroku was discussed over here as well: #90 (comment)

Not sure if DHH still has an opposing view on the topic.

from webpacker.

sealocal avatar sealocal commented on May 5, 2024

@gauravtiwari Thanks for the input! Did you grab that yarn.config snippet from StackOverflow? You'll see my comment right below it : D

I get that there are pre/post deploy hooks on AWS, but I haven't found the right combination that works for me. That particular yarn.config file is for a AWS Elastic Beanstalk Node Platform, where I'm running a Ruby platform. I haven't found the magic combination of commands to issue to AWS on deploy to get yarn installed. Perhaps I'm thinking of it wrong, and I should just install yarn manually upon setting up the application - which I have been able to solve.

from webpacker.

gauravtiwari avatar gauravtiwari commented on May 5, 2024

@sealocal Yeah, unfortunately I haven't used beanstalk, just EC2 :)

Is it not possible to manually install node.js platform too alongside ruby one?

from webpacker.

sealocal avatar sealocal commented on May 5, 2024

Actually node and npm are installed on the Ruby platform, but installing yarn so that the webapp user as global access to yarn (so that ./bin/yarn runs from the Rails root) has still been a challenge for me. I've had success installing globally twice, but failed to install multiple times, so my results are inconsistent.

from webpacker.

dleavitt avatar dleavitt commented on May 5, 2024

I believe even once your buildpacks are set correctly and NPM_CONFIG_PRODUCTION is set to false your compilation will still fail due to a problem with the vue preset (see below.) All the more reason to spin these off into separate repos per #124.

Added a #125 so that errors like the below are actually visible. Will maybe add another PR to update the README with some Heroku instructions.

Module build failed: Error: 

Vue packages version mismatch:

- [email protected]
- [email protected]

This may cause things to work incorrectly. Make sure to use the same version for both.
If you are using vue-loader@>=10.0, simply update vue-template-compiler.
If you are using vue-loader@<10.0 or vueify, re-installing vue-loader/vueify should bump vue-template-compiler to the latest.

@ytbryan Probably need to specify the vue versions in yarn add

from webpacker.

ytbryan avatar ytbryan commented on May 5, 2024

@dleavitt this PR should fix the error.

Perhaps, in the short run, webpacker might wish to give a warning note to users on managing dependencies with./bin/yarn

from webpacker.

swrobel avatar swrobel commented on May 5, 2024

I was having this issue on Heroku and realized it was because yarn won't install devDependencies when NODE_ENV=production. I fixed this by setting heroku config:set YARN_PRODUCTION=false

from webpacker.

gauravtiwari avatar gauravtiwari commented on May 5, 2024

@swrobel This is fixed on master, please do bundle update and try again. Let me know.

from webpacker.

swrobel avatar swrobel commented on May 5, 2024

@gauravtiwari fixed on master without the ENV var, thanks!

from webpacker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.