Log a weird error

I wrote a Node.js demo project and a command line version of the to-do-list. When writing unit tests, I started with a simple Jest test case

An error message was reported when yarn test was run

The error message is

Test suite failed to run

Cannot find module 'source-map-support'

at runTestInternal (node_modules/jest-runner/build/runTest.js:328:15)
Copy the code

Environmental information

  • Windows 10 Professional 1909
  • Yarn v1.19.0
  • The node v10.19.0
  • NPM v6.13.4

Other hardware configurations are as follows,

Some try

Next, I tried these steps:

  1. yarn add source-map-support
  2. Delete node-modules and reinstall
  3. Let someone else download and install, and the problem does not recur
  4. Upgrade a node from V10.19.0 to V12.18.0
  5. Upgrading YARN to the Latest Version (1.22.4)

The result is all not good, looked for a circle on the net, also did not check the same report error. And then, funnily enough, the problem was solved with a single command.

The solution

npm install source-map-support

Error reason

Yarn install source-map-support.js file source-map-support.js file source-map-support.js

conclusion

Some people say that YARN is more stable than NPM. In fact, YARN is not necessarily better than NPM. For example, the installed package is defective.