Webpacker: Yarn workspaces and webpacker.

Created on 6 Jun 2018  路  4Comments  路  Source: rails/webpacker

I am using Yarn workspaces for ease of development in my monorepo.

When I run the assets:precompile task from my rails project root I am getting the following:

"/webpack_runner.rb:11:in `exec': No such file or directory - /.../node_modules/.bin/webpack (Errno::ENOENT)"

This is obvious since webpacker (WebpackRunner more specifically) assumes that yarn has installed webpack and webpack-dev-server into the local node_modules folder cmd = [ "#{@node_modules_path}/.bin/webpack", "--config", @webpack_config ] + @argv.

Should Yarn workspaces be symlinking local node_modules/.bin to the top level node_modules/.bin or should webpacker be catering for hoisted binaries?

Most helpful comment

I was able to work around this by using the "nohoist" config for yarn workspaces. I added this to the Rails package.json:

"workspaces": {
    "nohoist": [
      "**/@rails/**"
    ]
  },

This forces yarn to not install @rails/* packages (including @rails/webpacker) in the workspace parent but locally. This, then drops the webpack file in .bin that webpacker sees.

All 4 comments

This is the only reason we still use npm, they handle bins a bit different. :shipit:

I was able to work around this by using the "nohoist" config for yarn workspaces. I added this to the Rails package.json:

"workspaces": {
    "nohoist": [
      "**/@rails/**"
    ]
  },

This forces yarn to not install @rails/* packages (including @rails/webpacker) in the workspace parent but locally. This, then drops the webpack file in .bin that webpacker sees.

I was able to work around this by using the "nohoist" config for yarn workspaces. I added this to the Rails package.json:

"workspaces": {
    "nohoist": [
      "**/@rails/**"
    ]
  },

This forces yarn to not install @rails/* packages (including @rails/webpacker) in the workspace parent but locally. This, then drops the webpack file in .bin that webpacker sees.

Solved my problem, thanks legend!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eriknygren picture eriknygren  路  3Comments

christianrojas picture christianrojas  路  3Comments

itay-grudev picture itay-grudev  路  3Comments

ijdickinson picture ijdickinson  路  3Comments

pioz picture pioz  路  3Comments