heroku / heroku-buildpack-nodejs

Heroku's buildpack for Node.js applications.
https://devcenter.heroku.com/articles/buildpacks
MIT License
3 stars 1 forks source link

Yarn postInstall fails when there's some dev dependencies in package.json #354

Closed ezakto closed 7 years ago

ezakto commented 7 years ago

This is my package.json:

{
  "name": "test",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "babel-preset-es2015": "^6.18.0",
    "babelify": "^7.3.0",
    "browserify": "^13.1.1",
    "watchify": "^3.8.0"
  },
  "scripts": {
    "start": "node index",
    "build": "browserify -t babelify src/main.js -o public/js/main.js",
    "watch": "watchify -t babelify src/main.js -o public/js/main.js",
    "postinstall": "yarn run build"
  }
}

The app deploys just fine. But, if I move remove watchify from dependencies and add it to devDependencies, there's an error in the postInstall step: Error: Cannot find module 'through2'. I think this is not yarn-related because it works just fine in local.

  "devDependencies": {
    "watchify": "^3.8.0"
  }

Buildpack: https://github.com/heroku/heroku-buildpack-nodejs#yarn

Full log:

remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Node.js app detected
remote: 
remote: -----> Creating runtime environment
remote:        
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NPM_CONFIG_PRODUCTION=true
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote: 
remote: -----> Installing binaries
remote:        engines.node (package.json):  unspecified
remote:        engines.npm (package.json):   unspecified (use default)
remote:        
remote:        Resolving node version (latest stable) via semver.io...
remote:        Downloading and installing node 6.9.1...
remote:        Using default npm version: 3.10.8
remote:        Downloading and installing yarn (latest)...
remote:        Installed yarn 0.17.10
remote: 
remote: -----> Restoring cache
remote:        Loading 2 from cacheDirectories (default):
remote:        - node_modules
remote:        - bower_components (not cached - skipping)
remote: 
remote: -----> Building dependencies
remote:        Installing node modules (yarn)
remote:        yarn install v0.17.10
remote:        [1/4] Resolving packages...
remote:        warning restify > node-uuid@1.4.7: use uuid module instead
remote:        [2/4] Fetching packages...
remote:        warning fsevents@1.0.15: The platform "linux" is incompatible with this module.
remote:        info "fsevents@1.0.15" is an optional dependency and failed compatibility check. Excluding it from installation.
remote:        [3/4] Linking dependencies...
remote:        [4/4] Building fresh packages...
remote:        $ yarn run build
remote:        yarn run v0.17.10
remote:        $ browserify -t babelify src/main.js -o public/js/main.js
remote:        module.js:471
remote:        throw err;
remote:        ^
remote:        
remote:        Error: Cannot find module 'through2'
remote:        at Function.Module._resolveFilename (module.js:469:15)
remote:        at Function.Module._load (module.js:417:25)
remote:        at Module.require (module.js:497:17)
remote:        at require (internal/module.js:20:19)
remote:        at Object.<anonymous> (/tmp/build_e4b857efab80621a94ed89bbd1b8faf5/node_modules/browserify/bin/cmd.js:4:15)
remote:        at Module._compile (module.js:570:32)
remote:        at Object.Module._extensions..js (module.js:579:10)
remote:        at Module.load (module.js:487:32)
remote:        at tryModuleLoad (module.js:446:12)
remote:        at Function.Module._load (module.js:438:3)
remote:        error Command failed with exit code 1.
remote:        info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
remote:        error Command failed with exit code 1.
remote:        info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
remote: 
remote: -----> Build failed
remote:        
remote:        We're sorry this build is failing! You can troubleshoot common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:        
remote:        Some possible problems:
remote:        
remote:        - Node version not specified in package.json
remote:        https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
remote:        
remote:        - A module may be missing from 'dependencies' in package.json
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys#ensure-you-aren-t-relying-on-untracked-dependencies
remote:        
remote:        - This module may be specified in 'devDependencies' instead of 'dependencies'
remote:        https://devcenter.heroku.com/articles/nodejs-support#devdependencies
remote:        
remote:        Love,
remote:        Heroku
remote:        
remote:  !     Push rejected, failed to compile Node.js app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to test.
remote: 
hunterloftis commented 7 years ago

Instead of the #yarn branch, just use the master branch (or don't specify a buildpack at all). Yarn support is now integrated into the platform.

To debug a specific app, please open a ticket.

If you have instructions to reproduce a buildpack issue, this is a good place.

ezakto commented 7 years ago

So silly. Yep, no errors using the master branch. Thanks!