yeno-team / suke

A web application to watch videos online with others.
0 stars 0 forks source link

[@suke/suke-web:bug] Module not found: Can't resolve 'aws-sdk' in dev branch #87

Closed khai93 closed 2 years ago

khai93 commented 2 years ago

Full Error

Module not found: Can't resolve 'aws-sdk' in 'C:\Users\user\Documents\Projects\suke\node_modules\@mapbox\node-pre-gyp\lib\util'

khai93 commented 2 years ago

Alright, a lot to go over...

So first things first actual intended problem this issue was supposed to solve. If you get an error message like above, see the solution below.

Issue Solution

in craco.config.js, In overrideWebpackConfig plugin, you'll see I added a new line I the bottom, webpack.externals = [...]. This array basically tells webpack to ignore these dependencies. Every single package in there is causing that same error above in the issue message.

TLDR: add the package name to webpack.externals array

Extra stuff brought by this issue

Different Node and JS packages

The only package that was not compatible with browsers is bcrypt which was meant for node. I've switched to bcryptjs since just importing bcrypt will crash a react application. This is only a problem because we share codebases between the server and the client.

TypeORM strict type

I have no idea why this even showed up now, THIS never happened before. The solution is to explicitly put the type in the @Column decorator. Like @Column('text') or @Column({type: 'text'}). The type names MATTER, please check if the type is supported by our database here https://github.com/typeorm/typeorm/blob/master/src/driver/types/ColumnTypes.ts.

Strict Dependency Hoist is now enabled.

During the search for the solution to this issue, I stumbled upon the setting nmHoistingLimits in .yarnrc.yml. This didn't fix the issue however I'm going to keep this setting active. This setting will help keep bugs in check in the future. There are a few options for this setting that you can check out yourself but I set it as the dependencies option. This means that all node packages will be hoisted up to the dependency level. This allows local and global scopes to node_modules and allows safer installation process to packages.

Important Changes

Time Elapsed: 7 hours

khai93 commented 2 years ago

Also if you are in an older branch, be sure to remove node_modules and yarn.lock then a normal yarn just in case.