Skip to content

Unable to write asset to disk: TypeError: chalk is not a function #310

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

Closed
1 task done
Izhaki opened this issue May 21, 2018 · 3 comments
Closed
1 task done

Unable to write asset to disk: TypeError: chalk is not a function #310

Izhaki opened this issue May 21, 2018 · 3 comments
Labels

Comments

@Izhaki
Copy link

Izhaki commented May 21, 2018

  • Operating System: OSX 10.12.6
  • Node Version: 8.4.0
  • NPM Version: 6.0.1
  • webpack version: 4.8.1
  • webpack-dev-middleware Version: 3.1.3
  • This is a bug

This relates to #291

Code

const webpack = require('webpack');
const middleware = require('webpack-dev-middleware');
const webpackConfig = require('../build/webpack.dev');
const compiler = webpack(webpackConfig);

const app = express();

app.use(middleware(compiler, {
  publicPath: '/app/scripts_amd',
  stats: {
    cached: false,
  },
  writeToDisk: true
}));

Expected Behavior

Files being written to disk.

Actual Behavior

TypeError: chalk is not a function
✖ 「wdm」: Unable to write asset to disk:

How can we reproduce the behavior?

It seems you only need to install the versions described above, with the config above.

More details.

With 3.1.3:

This seems to be the result of this PR #293

/lib/fs.js:

const { chalk } = require('webpack-log');

package.json

"webpack-log": "^1.0.1"

But that version of webpack-log does not export chalk. Version 1.2.0 does.

Fix:

Upgrade webpack-log to 1.2.0.

@shellscape
Copy link
Contributor

Thanks for the issue 🍺

The semver pattern ^1.0.1 matches 1.2.0 so this is probably an issue on your end. All tests pass and a fresh install (npm 6.x should respect package-lock).

@Izhaki
Copy link
Author

Izhaki commented May 28, 2018

Right then!

So there we have it... on a scale...

Option 1: ~45 minutes per person.

People like me, who are going to get a TypeError; have no idea how to solve it; spend time figuring out why that is; hit a few confounds; possibly hitting this issue to learn you need a fresh install despite the fact that their lock file (locked to 1.0.1) is valid.

All that time spent we could have done something better for others, whether our children or fellow developers.

Option 2: 5 minute.

You update your dependencies.

The fact that ^1.0.1 matches 1.2.0 is an argument loose as rabbit skin - your product doesn't work with 1.0.1 and you are leaving all of us in the mercy of utterly invisible logic and high-breakage potential.


So how is option 1 better than 2? @shellscape

@shellscape
Copy link
Contributor

Yep, lockfiles can be tricky that's for sure. Fortunately you've gleaned a good deal of knowledge you can use in the future. I'm sorry you feel strongly about webpack-dev-middleware being broken and not working. Unfortunately the issue was hiding on your end.

The tone and timber in your last message has taken on a bit of a high tension direction, so I'm going to lock this one to contributors for a bit.

@webpack webpack locked as too heated and limited conversation to collaborators May 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants