Search code examples
angulargoogle-cloud-buildmodulenotfounderror

Getting error 'Cannot find module' on server but local works


I'm creating this error in order to help other developer who could have the same problem. I spent some time on it and the solution is pretty easy.

The scenario was: everything was working fine locally and I double checked if the configuration in cloubuild was the same. (In my case, it happened on cloudbuild, but it could happen on any server)

But there, I got the following error:

./src/app/shared/markdown-editor/markdown-editor.constant.ts:56:0-35 - Error: Module not found: Error: Can't resolve 'easyMDE' in '/workspace/frontend/src/app/shared/markdown-editor'

./src/app/shared/markdown-editor/markdown-editor.directive.ts:620:0-35 - Error: Module not found: Error: Can't resolve 'easyMDE' in '/workspace/frontend/src/app/shared/markdown-editor'

Error: src/app/shared/markdown-editor/markdown-editor.constant.ts:1:26 - error TS2307: Cannot find module 'easyMDE' or its corresponding type declarations.

1 import * as EasyMDE from 'easyMDE';
                           ~~~~~~~~~


Error: src/app/shared/markdown-editor/markdown-editor.directive.ts:2:26 - error TS2307: Cannot find module 'easyMDE' or its corresponding type declarations.

2 import * as EasyMDE from 'easyMDE';

The point is: Local everything was working but I was in a macOS and it is not case sensitive, but cloudbuild is linux based.


Solution

  • In order to solve it, check if the library you are using has capital letters and use only lower-case letters:

    import * as EasyMDE from 'easymde';
    

    instead of:

    import * as EasyMDE from 'easyMDE';