1

I'm facing an issue while running Jasmine tests for my project. When I execute the command jasmine in my project directory, I encounter the following error:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\Users\faris\Desktop\KODING\DICODING\dicoding-expert-3\src\scripts\utils\like-button-initiator' imported from C:\Users\faris\Desktop\KODING\DICODING\dicoding-expert-3\specs\sampleTestSpec.js
    at new NodeError (node:internal/errors:399:5)
    at finalizeResolution (node:internal/modules/esm/resolve:326:11)
    at moduleResolve (node:internal/modules/esm/resolve:945:10)
    at defaultResolve (node:internal/modules/esm/resolve:1153:11)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
    at link (node:internal/modules/esm/module_job:76:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

I have already added "type": "module" in my package.json file to enable ES modules. The file like-button-initiator is located at the specified path 'C:\Users\faris\Desktop\KODING\DICODING\dicoding-expert-3\src\scripts\utils\like-button-initiator', and the test file sampleTestSpec.js imports it.

I have tried different solutions, such as verifying the file path, reinstalling dependencies, and confirming that the file exists. However, the error persists.

Can someone please help me understand the cause of this error and suggest a possible solution? Thank you!

I have tried the following steps to resolve the issue:

  1. Added "type": "module" to my package.json file to enable ES modules.
  2. Verified the file path of like-button-initiator located at 'C:\Users\faris\Desktop\KODING\DICODING\dicoding-expert-3\src\scripts\utils\like-button-initiator'.
  3. Reinstalled project dependencies.
  4. Confirmed that the like-button-initiator file exists at the specified path.
  5. Ensured that the sampleTestSpec.js file correctly imports like-button-initiator.

I was expecting the Jasmine tests to run successfully without encountering the ERR_MODULE_NOT_FOUND error. However, despite taking these steps, the error persists. I'm looking for insights or alternative solutions to resolve this issue. Thank you!

0 Answers0