With RequireJS cannot load from node_modules but can from directory from ZIP

This is strange. I installed the codemirror package (5.57.0) with npm and added it to requirejs.config() this way:

packages: [{
            name: "codemirror",
            // location: "../libs/codemirror-5.57.0",
            location: "../node_modules/codemirror",
            main: "lib/codemirror"
 }]

The loading fails with a timeout, that is, RequireJS finds the file but there is a problem loading it.
If I download the zip file and put the content in the commented path above, after changing the location entry it loads without problems. Even if I move the ../libs/codemirror-5.57.0 directory under node_modules (adjusting location) it loads fine.

The differences between the two directories are obvious: the test and build files are missing under the package. Currently I’m removing one by one the files in the ZIP version to see what is critical for loading.

Any idea?
Thanks!
mario

This problem is driving me insane.

Just if I copy the codemirror.js file in another directory (for example at the same level of node_modules or just a directory up) and everything works.

The various addons / modes still reference the original file, seems.

All considered seems the problem is no more of codemirror, but of RequireJS, so I move the discussion there. Anyway, any idea is very welcome.

Thanks!
mario