Failed to load service '/MY_LOCAL_PATH/minio.svc.ts' Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './src/errors' is not defined by "exports" in /node_modules/moleculer/package.json
at new NodeError (node:internal/errors:387:5)
at throwExportsNotFound (node:internal/modules/esm/resolve:464:9)
at packageExportsResolve (node:internal/modules/esm/resolve:748:3)
at resolveExports (node:internal/modules/cjs/loader:493:36)
at Function.Module._findPath (node:internal/modules/cjs/loader:533:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:942:27)
at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (/usr/local/lib/node_modules/ts-node/node_modules/@cspotcode/source-map-support/source-map-support.js:679:30)
at Function.Module._load (node:internal/modules/cjs/loader:804:27)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
Solution
If you change the way to import Errors from Molecuer you will resolve this problem.
// Current import way
const {MoleculerRetryableError} = require("moleculer/src/errors");
// Correct way
// Option 1
const {MoleculerRetryableError} = require("moleculer").Errors;
// Option 2
const {Errors } = require("moleculer"); //Errors.MoleculerRetryableError
Versions
node 16.17.0 moleculer 0.14.23 minio 7.0.23
My service
Error
Solution
If you change the way to import Errors from Molecuer you will resolve this problem.