sinonjs / sinon

Test spies, stubs and mocks for JavaScript.
https://sinonjs.org/
Other
9.66k stars 772 forks source link

Uses sinonjs with faker-timers => Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/sinon/util/fake-timers' is not defined by "exports" #2420

Closed franckOL closed 2 years ago

franckOL commented 2 years ago

Describe the bug After upgrade on latest version for sinonjs (mocha, rewire and other things), previously running tests now crash with error

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/sinon/util/fake-timers' is not defined by "exports" in F:\_Utilisateur\Project\SmartDust\energy\nanocptscenariorunner\node_modules\sinon\package.json
    at new NodeError (node:internal/errors:371:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:440:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:692:3)
    at resolveExports (node:internal/modules/cjs/loader:482:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
franckOL commented 2 years ago

Found the problem. Bad import in my code:

const { clock } = require('sinon/lib/sinon/util/fake-timers')