NPM doesn't install module dependencies when deploying a Grunt app to heroku

前端 未结 3 1052
无人及你
无人及你 2021-02-15 12:14

I\'v made a static single page site using grunt. I\'m now trying to deploy it to heroku using the heroku-buildpack-nodejs-grunt for node grunt.

Below is a pic of my roo

3条回答
  •  耶瑟儿~
    2021-02-15 12:59

    The only thing I can think of is that maybe Heroku installs your devDependencies first, tries to run Grunt, but since it didn't install load-grunt-tasks yet, you don't get the grunt.loadNpmTasks( 'grunt-contrib-uglify' ); line (which load-grunt-tasks does for you), and thus Grunt can't find the package.

    Can you try changing your Gruntfile to explicitly list out all npm modules using the grunt.loadNpmTasks() method?

    EDIT:

    Just remembered another thing I had to do:

    heroku labs:enable user-env-compile -a myapp
    heroku config:set NODE_ENV=production
    

    (Obviously replacing myapp with your Heroku app name.)

    This makes Heroku allow user set environment variables and then sets your server to production. Try that, and set your dependencies and devDependencies as you had them originally (just to see if it works).

提交回复
热议问题