ably-js
ably-js copied to clipboard
Critical Dependency - got / keyv
Upon installing Ably with npm install I now receive the following errors on my logs:
Critical dependency: the request of a dependency is an expression
Import trace for requested module:
./node_modules/keyv/src/index.js
./node_modules/ably/node_modules/cacheable-request/src/index.js
./node_modules/ably/node_modules/got/dist/source/core/index.js
./node_modules/ably/node_modules/got/dist/source/create.js
./node_modules/ably/node_modules/got/dist/source/index.js
./node_modules/ably/build/ably-node.js
./node_modules/ably/promises.js
./app/api/create-token-request/route.ts
Some initial research led to the solution of "just closing my eyes" but for our project that is an unacceptable fix. How can I address this problem derived from the install of Ably?
I am using Next.js 13
➤ Automation for Jira commented:
The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-3608
Hey @starlight-akouri thanks for reporting this! Unfortunately this is not easy for us to fix right now - unless webpack/kv/cachable-request/got fix it on their end then the only thing we could do is migrate to an alternative nodejs http client.
I know the "close your eyes" comment isn't exactly reassuring but this isn't really a security issue or anything, it just means that some tools which trace modules might not be able to find all the dependencies of keyv. As long as ably-js is able to make an http request in your environment then there shouldn't be an issue.
There are a couple of suggested fixes in the keyv issue which might be worth trying if you'd like to get rid of the warning eg: https://github.com/jaredwray/keyv/issues/45#issuecomment-1079958339
I received the same warning. I know it's not causing any errors, but it's super annoying.
For those who wants to ignore the warning, you can refer to https://github.com/sindresorhus/got/issues/2267#issuecomment-1659768856
/** @type {import('next').NextConfig} */
const nextConfig = {
// ...
webpack: (config) => {
// Ignore ALL webpack warnings produced by ./node_modules/keyv/src/index.js file
config.ignoreWarnings = [
{ module: /node_modules\/keyv\/src\/index\.js/ },
];
return config;
},
};
module.exports = nextConfig;
Updating the suggested solution for this:
You should add the next line to your next.config.js file:
const nextConfig = {
// ...
experimental: {
serverComponentsExternalPackages: ['ably'],
},
};
You can read more about what is causing this in our README section and in next issue's comment: https://github.com/ably/ably-js/issues/1699#issuecomment-2022702584.
Closing this issue as this warning is not caused by Ably.