Building typeorm with webpack: Module not found error
See original GitHub issueIssue type:
[X] question [ ] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql
/ mariadb
[X] oracle
[ ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[X] latest
[ ] @next
[ ] 0.x.x
(or put your version here)
Steps to reproduce or a small repository showing the problem:
- Clone repo https://github.com/typeorm/typescript-example
- npm install dependencies
- run web pack
Any pointers will be greatly appreciated. Thanks
Here is my webpack config
module.exports = [ { entry: './src/index.ts', target: 'node', mode, devtool, module: { rules: [ { test: /\.tsx?$/, use: 'ts-loader', exclude: /node_modules/ } ] }, resolve: { extensions: [ '.tsx', '.ts', '.js' ] }, output: { filename: 'server.js', path: path.resolve(__dirname, 'dist') }, node: { __dirname: false, __filename: false, } } ];
Build Errors
WARNING in ./node_modules/parse5/lib/index.js 55:23-49 Critical dependency: the request of a dependency is an expression @ ./node_modules/cli-highlight/dist/index.js @ ./node_modules/typeorm/platform/PlatformTools.js @ ./node_modules/typeorm/index.js @ ./src/index.ts
WARNING in ./node_modules/app-root-path/lib/app-root-path.js 14:10-56
Critical dependency: the request of a dependency is an expression
@ ./node_modules/app-root-path/index.js
@ ./node_modules/typeorm/platform/PlatformTools.js
@ ./node_modules/typeorm/index.js
@ ./src/index.ts
WARNING in ./node_modules/typeorm/platform/PlatformTools.js 112:23-85
Critical dependency: the request of a dependency is an expression
@ ./node_modules/typeorm/index.js
@ ./src/index.ts
WARNING in ./node_modules/typeorm/platform/PlatformTools.js 107:27-40
Critical dependency: the request of a dependency is an expression
@ ./node_modules/typeorm/index.js
@ ./src/index.ts
WARNING in ./node_modules/typeorm/platform/PlatformTools.js
Module not found: Error: Can't resolve 'ioredis' in '/Users/bgottip/Desktop/template/webpack_orm/typescript-example/node_modules/typeorm/platform'
@ ./node_modules/typeorm/platform/PlatformTools.js
@ ./node_modules/typeorm/index.js
@ ./src/index.ts
WARNING in ./node_modules/typeorm/platform/PlatformTools.js
Module not found: Error: Can't resolve 'mongodb' in '/Users/bgottip/Desktop/template/webpack_orm/typescript-example/node_modules/typeorm/platform'
@ ./node_modules/typeorm/platform/PlatformTools.js
@ ./node_modules/typeorm/index.js
@ ./src/index.ts
WARNING in ./node_modules/typeorm/platform/PlatformTools.js
Module not found: Error: Can't resolve 'mssql' in '/Users/bgottip/Desktop/template/webpack_orm/typescript-example/node_modules/typeorm/platform'
@ ./node_modules/typeorm/platform/PlatformTools.js
@ ./node_modules/typeorm/index.js
@ ./src/index.ts
WARNING in ./node_modules/typeorm/platform/PlatformTools.js
Module not found: Error: Can't resolve 'mysql2' in '/Users/bgottip/Desktop/template/webpack_orm/typescript-example/node_modules/typeorm/platform'
@ ./node_modules/typeorm/platform/PlatformTools.js
@ ./node_modules/typeorm/index.js
@ ./src/index.ts
WARNING in ./node_modules/typeorm/platform/PlatformTools.js
Module not found: Error: Can't resolve 'oracledb' in '/Users/bgottip/Desktop/template/webpack_orm/typescript-example/node_modules/typeorm/platform'
@ ./node_modules/typeorm/platform/PlatformTools.js
@ ./node_modules/typeorm/index.js
@ ./src/index.ts
WARNING in ./node_modules/typeorm/platform/PlatformTools.js
Module not found: Error: Can't resolve 'pg' in '/Users/bgottip/Desktop/template/webpack_orm/typescript-example/node_modules/typeorm/platform'
@ ./node_modules/typeorm/platform/PlatformTools.js
@ ./node_modules/typeorm/index.js
@ ./src/index.ts
WARNING in ./node_modules/typeorm/platform/PlatformTools.js
Module not found: Error: Can't resolve 'pg-native' in '/Users/bgottip/Desktop/template/webpack_orm/typescript-example/node_modules/typeorm/platform'
@ ./node_modules/typeorm/platform/PlatformTools.js
@ ./node_modules/typeorm/index.js
@ ./src/index.ts
WARNING in ./node_modules/typeorm/platform/PlatformTools.js
Module not found: Error: Can't resolve 'pg-query-stream' in '/Users/bgottip/Desktop/template/webpack_orm/typescript-example/node_modules/typeorm/platform'
@ ./node_modules/typeorm/platform/PlatformTools.js
@ ./node_modules/typeorm/index.js
@ ./src/index.ts
WARNING in ./node_modules/typeorm/driver/react-native/ReactNativeDriver.js
Module not found: Error: Can't resolve 'react-native-sqlite-storage' in '/Users/bgottip/Desktop/template/webpack_orm/typescript-example/node_modules/typeorm/driver/react-native'
@ ./node_modules/typeorm/driver/react-native/ReactNativeDriver.js
@ ./node_modules/typeorm/driver/DriverFactory.js
@ ./node_modules/typeorm/connection/Connection.js
@ ./node_modules/typeorm/index.js
@ ./src/index.ts
WARNING in ./node_modules/typeorm/platform/PlatformTools.js
Module not found: Error: Can't resolve 'redis' in '/Users/bgottip/Desktop/template/webpack_orm/typescript-example/node_modules/typeorm/platform'
@ ./node_modules/typeorm/platform/PlatformTools.js
@ ./node_modules/typeorm/index.js
@ ./src/index.ts
WARNING in ./node_modules/typeorm/platform/PlatformTools.js
Module not found: Error: Can't resolve 'sql.js' in '/Users/bgottip/Desktop/template/webpack_orm/typescript-example/node_modules/typeorm/platform'
@ ./node_modules/typeorm/platform/PlatformTools.js
@ ./node_modules/typeorm/index.js
@ ./src/index.ts
WARNING in ./node_modules/typeorm/platform/PlatformTools.js
Module not found: Error: Can't resolve 'sqlite3' in '/Users/bgottip/Desktop/template/webpack_orm/typescript-example/node_modules/typeorm/platform'
@ ./node_modules/typeorm/platform/PlatformTools.js
@ ./node_modules/typeorm/index.js
@ ./src/index.ts
Issue Analytics
- State:
- Created 4 years ago
- Reactions:12
- Comments:5 (1 by maintainers)
Yes, but that’s a while ago… I can not remember all the steps. I found that I need add externals configuration to the webpack.prod.js and webpack.dev.js as follow:
I hope this help you.
I got the same error when my
webpack.config.js
(with node target) was not in my project root-directory but in a subfolder. The problem was with the configuration of thewebpack-node-externals
was not finding thenode_modules
:I resolved the error by: changing this:
nodeExternals()
into this:
Before applying this fix my webpack bundle was huge as it would bundle the node_modules - causing the warnings along the way…