Can't resolve 'bufferutil' and 'utf-8-validate'

See original GitHub issue

on netlify-lambda build

WARNING in /home/nicky/projects/jason-api/node_modules/subscriptions-transport-ws/node_modules/ws/lib/buffer-util.js
not found: Error: Can't resolve 'bufferutil' in '/home/nicky/projects/jason-api/node_modules/subscriptions-transport-ws/node_modules/ws/lib'

WARNING in /home/nicky/projects/jason-api/node_modules/subscriptions-transport-ws/node_modules/ws/lib/validation.js
not found: Error: Can't resolve 'utf-8-validate' in '/home/nicky/projects/jason-api/node_modules/subscriptions-transport-ws/node_modules/ws/lib'

Despite those errors, ./netlify/functions/graphql still works locally after running netlify-lambda serve

The repo I’m having this issue in is also the mininal reproduction https://github.com/NickyMeuleman/jason-api

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

43reactions
glennreyescommented, Sep 14, 2019

This can be solved by configuring your webpack externals:

//webpack.functions.js
const nodeExternals = require('webpack-node-externals');

module.exports = {
  externals: [nodeExternals()],
};

However, imho it is more reasonable to have this set up by default so there’s no hassle with a custom webpack config when setting up a graphql lambda.

@sw-yx Any thoughts or objections on having this config by default? I’d be happy to open a PR adding it!

2reactions
Jesuspinartecommented, May 4, 2022

The solution for me was add this ti my next.config.js:

const nodeExternals = require('webpack-node-externals');

const nextConfig = {
  reactStrictMode: true,
};

module.exports = {
  ...nextConfig,
  webpack: (config, { isServer }) => {
    if (!isServer) {
      config.externals = [nodeExternals()];
    }

    return config;
  },
};

I’m using Next 12.1.5

Read more comments on GitHub >

github_iconTop Results From Across the Web

utf-8-validate - npm
Check if a buffer contains valid UTF-8. Latest version: 5.0.10, last published: 2 months ago. Start using utf-8-validate in your project by ...
Read more >
Warnings when building backend Express/WS Node app with ...
The short answer. webpack can work with node, but it cannot extract follow require() statements. Modifications have to be made to ignore ...
Read more >
Usage with bundlers | Socket.IO
Note: bufferutil and utf-8-validate are two optional dependencies from the ws package. You can also set them as "external" with:.
Read more >
Error installing from npm: socket.io-client. Unable to resolve ...
Unable to resolve some modules: "bufferutil" in /Users/admin/Desktop/x/node_modules/ws/lib/BufferUtil.js (web.browser) "utf-8-validate" in ...
Read more >
fixing warnings when bundling Colyseus server with webpack
node_modules/colyseus/node_modules/ws/lib/buffer-util.js Module not found: ... Module not found: Error: Can't resolve 'utf-8-validate' in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found