Netlify cli error when importing imagekit npm package

I have a nuxtjs project deployed here

I’m running it locally with netlify dev without any problem.

As soon I install and import the imagekit npm package in a netlify function file, I get this error running netlify dev:

 > ../../../../../usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/utils/detect_native_module.js:14:32: error: [plugin: external-native-modules] files.some is not a function
    14 │     const hasBinaryFile = files.some((path) => !path.startsWith('!') && (0, path_1.extname)(path) === '.node');
       ╵                                 ^
    at isNativeModule (/usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/utils/detect_native_module.js:14:33)
    at /usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/esbuild/plugin_native_modules.js:17:158
    at /usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/esbuild/plugin_native_modules.js:35:57
    at callback (/usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/esbuild/lib/main.js:833:28)
    at handleRequest (/usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/esbuild/lib/main.js:644:30)

   ../../../../../usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/esbuild/plugin_native_modules.js:26:14: note: This error came from the "onResolve" callback registered here
    26 │         build.onResolve({ filter: packageFilter }, async (args) => {
       ╵               ~~~~~~~~~
    at setup (/usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/esbuild/plugin_native_modules.js:26:15)
    at handlePlugins (/usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/esbuild/lib/main.js:746:23)
    at Object.buildOrServe (/usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/esbuild/lib/main.js:1094:7)
    at /usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/esbuild/lib/main.js:1818:17
    at new Promise (<anonymous>)
    at Object.build (/usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/esbuild/lib/main.js:1817:14)
    at build (/usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/esbuild/lib/main.js:1693:51)
    at bundleJsFile (/usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/esbuild/bundler.js:60:96)
    at Object.bundle (/usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/esbuild/index.js:33:150)

   node_modules/imagekit/dist/utils/phash.js:7:49: note: The plugin "external-native-modules" was triggered by this import
     7 │ var hamming_distance_1 = __importDefault(require("hamming-distance"));
       ╵  

I successfully used that package on other projects not on netlify without any issue.

What can be the problem?

Hey @giovanni

Something doesn’t seem quite right here. Are you able to share the git repository you are deploying from?

Hi @coelmay

This is the repo: esc-py

Thanks @giovanni

I see nowhere in the codebase where imagekit is imported. Can you demonstrate where/how this import happens?

Sorry, it was in the local repository.

I pushed on github now.

It’s in netlify > functions > get-models.js

I am able to replicate this locally, so it is possibly suggestive of a bug in Netlify CLI. You might like to file a bug report on the Netlify CLI repository

done

Thank you!