Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Node complain about import library when its all there

Im trying to write a node script using a third party library (@craftzing/akeneo-api) and even before using the library, just at the import statement I get an error as its missing a module. It does find the akeneo-api module, but this module itself imports from its own files a http-client and it fails to import this (even if the file is there). I tried commenting the http-client import to see if it was a particular problem with it, but it fails with the next import, so for some reason it is failing to load the imports inside of the library I am using.

Any ideas?

% node scripts/sync.js
node:internal/errors:477
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/test/scripts/node_modules/@craftzing/akeneo-api/dist/mjs/http-client' imported from /Users/test/scripts/node_modules/@craftzing/akeneo-api/dist/mjs/index.js
    at new NodeError (node:internal/errors:387:5)
    at finalizeResolution (node:internal/modules/esm/resolve:429:11)
    at moduleResolve (node:internal/modules/esm/resolve:1006:10)
    at defaultResolve (node:internal/modules/esm/resolve:1214:11)
    at nextResolve (node:internal/modules/esm/loader:165:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:844:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:431:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
    at link (node:internal/modules/esm/module_job:75:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

This is the script so far (just the import)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

import client from '@craftzing/akeneo-api';
console.log('test');

>Solution :

You should be able to resolve the issue by including --es-module-specifier-resolution=node in your node command. As in

node --es-module-specifier-resolution=node scripts/sync.js
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading