Help With "Deploying our app" tests

Greetings, I’m getting an error code on attempts to use the command “npm run test”

Error: Cannot find module ‘C:\Users\UserName\Git Tests\will-it-miss\tests*.js’
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: ‘MODULE_NOT_FOUND’,
requireStack: []
}

I assumed, from reading this error, that this means the file for the nasa test in the learning section is unable to be found at the specified location. I have checked the file path to ensure it is in the path in the same location as Cannot find module ‘C:…’. I additionally ensured that the code was done correctly, for the nasa-feed.test.js and the package.json files. If anyone else has had this issue, or has found a workaround please let me know at the earliest convenience, as everything appears to be correct.

Thanks in advance!

Hi @gbruch and welcome to the community :wave:

I haven’t done this exercise myself, but what looks suspicious is the path:
C:\Users\UserName\Git Tests\will-it-miss\tests*.js
Normally, test files would go into their own directory. Looking at your path above it seems like the test files are directly in the project directory and start with “tests” and end with “.js”. Is it possible that the path should be:
C:\Users\UserName\Git Tests\will-it-miss\tests\*.js
It would then refer to all JS files inside the “tests” directory. Maybe “scripts” -> “test” in package.json is missing the backslash.

Have a nice day,
Michael

1 Like

Hey @gbruch! Welcome to the MDN Web Docs learning community.
Can you provide a link to the code exercise you are following?


Schalk
Staff Community Manager - MDN Web Docs

1 Like

Hi @schalkneethling

It’s from “Tools and testing - Client-side web development tools”:

1 Like

Hey @gbruch,

Looking at this line:

C:\Users\UserName\Git Tests\will-it-miss\tests*.js

Can you please double check that the following line in your package .json:

"test": "node tests/*.js",

Is typed as "test": "node tests/*.js", and not “test”: “node tests*.js”,`. Notice the missing forward slash(/). Let me know if this helps solve your problem.


Schalk
Staff Community Manager - MDN Web Docs

Hello.

I am having exactly the same problem, except that I have no typo in the definition of the test command like gbruch had in his initial question. In the scripts section of package.json I have

“test”: “node tests/*.js”,
“build”: “npm run test && parcel build src/index.html”

The complete error node throws:

node:internal/modules/cjs/loader:949
  throw err;
  ^

Error: Cannot find module 'C:\Users\thors\Desktop\will-it-miss\tests\*.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:946:15)
    at Module._load (node:internal/modules/cjs/loader:787:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Any further ideas?

Thank you in advance,
Thorsten

1 Like

Hi,have you solved your problem? Now I have the same problem, I tried to replace “ *.js ” with “ nasa-feed.test.js ”,it worked. But I still want to know what the problem is.

Hi,

I am going through this article and I also have this problem can anyone tell me how to solve this?

It is saying:
Error: Cannot find module will-it-miss\tests\*.js'