Reputation: 684
I googled the issue for a while and found several posts on the typeorm
github, but they were all closed without a solution provided. It seem to be a webpack
issue, but I don't understand what the issue is exactly. The example compiles well for me.
It happens as soon as I call createConnection
, which is imported from typeorm
. The error I get is the following. I have cut off most of the "Can't resolve in ..." but you get the idea.
WARNING in ./node_modules/typeorm/platform/PlatformTools.js
Module not found: Error: Can't resolve 'redis' in '/my/project/node_modules/typeorm/platform'
@ ./node_modules/typeorm/platform/PlatformTools.js
@ ./node_modules/typeorm/index.js
@ ./src/main.ts
WARNING in ./node_modules/typeorm/platform/PlatformTools.js
Module not found: Error: Can't resolve 'sql.js' in '/my/project/node_modules/typeorm/platform'
@ ./node_modules/typeorm/platform/PlatformTools.js
@ ./node_modules/typeorm/index.js
@ ./src/main.ts
WARNING in ./node_modules/node-pre-gyp/lib/util/nw-pre-gyp/index.html 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
> <!doctype html>
| <html>
| <head>
@ ./node_modules/node-pre-gyp/lib sync ^\.\/.*$ ./util/nw-pre-gyp/index.html
@ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js
@ ./node_modules/sqlite3/lib/sqlite3.js
@ ./node_modules/typeorm/platform/PlatformTools.js
@ ./node_modules/typeorm/index.js
@ ./src/main.ts
WARNING in ./node_modules/node-gyp/lib/Find-VS2017.cs 7:6
Module parse failed: Unexpected token (7:6)
You may need an appropriate loader to handle this file type.
| // Usage:
| // powershell -ExecutionPolicy Unrestricted -Version "2.0" -Command "&{Add-Type -Path Find-VS2017.cs; [VisualStudioConfiguration.Main]::Query()}"
> using System;
| using System.Text;
| using System.Runtime.InteropServices;
@ ./node_modules/node-gyp/lib sync ^\.\/.*$ ./Find-VS2017.cs
@ ./node_modules/node-gyp/lib/node-gyp.js
@ ./node_modules/node-pre-gyp/lib/util/compile.js
@ ./node_modules/node-pre-gyp/lib sync ^\.\/.*$
@ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js
@ ./node_modules/sqlite3/lib/sqlite3.js
@ ./node_modules/typeorm/platform/PlatformTools.js
@ ./node_modules/typeorm/index.js
@ ./src/main.ts
ERROR in ./node_modules/node-pre-gyp/lib/unpublish.js
Module not found: Error: Can't resolve 'aws-sdk' in '/my/project/node_modules/node-pre-gyp/lib'
@ ./node_modules/node-pre-gyp/lib/unpublish.js 16:14-32
@ ./node_modules/node-pre-gyp/lib sync ^\.\/.*$
@ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js
@ ./node_modules/sqlite3/lib/sqlite3.js
@ ./node_modules/typeorm/platform/PlatformTools.js
@ ./node_modules/typeorm/index.js
@ ./src/main.ts
ERROR in ./node_modules/node-pre-gyp/lib/info.js
Module not found: Error: Can't resolve 'aws-sdk' in '/my/project/node_modules/node-pre-gyp/lib'
@ ./node_modules/node-pre-gyp/lib/info.js 14:14-32
@ ./node_modules/node-pre-gyp/lib sync ^\.\/.*$
@ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js
@ ./node_modules/sqlite3/lib/sqlite3.js
@ ./node_modules/typeorm/platform/PlatformTools.js
@ ./node_modules/typeorm/index.js
@ ./src/main.ts
ERROR in ./node_modules/node-pre-gyp/lib/publish.js
Module not found: Error: Can't resolve 'aws-sdk' in '/my/project/node_modules/node-pre-gyp/lib'
@ ./node_modules/node-pre-gyp/lib/publish.js 18:14-32
@ ./node_modules/node-pre-gyp/lib sync ^\.\/.*$
@ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js
@ ./node_modules/sqlite3/lib/sqlite3.js
@ ./node_modules/typeorm/platform/PlatformTools.js
@ ./node_modules/typeorm/index.js
@ ./src/main.ts
My package.json
(I removed some dependencies to shorten it a bit)
{
"name": "something-with-electron",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"prestart": "npm run build",
"start": "npm run build && electron ./dist/main.js",
"build": "webpack --config ./webpack.config.js",
"postinstall": "install-app-deps"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {},
"devDependencies": {
"@babel/cli": "^7.2.0",
"@babel/core": "^7.2.0",
"@babel/plugin-proposal-class-properties": "^7.2.1",
"@babel/preset-env": "^7.2.0",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.1.0",
"@blueprintjs/core": "^3.10.0",
"@types/lodash": "^4.14.119",
"@types/mime-types": "^2.1.0",
"@types/node": "^10.12.12",
"@types/react": "^16.7.13",
"@types/react-dom": "^16.0.11",
"@types/react-redux": "^6.0.11",
"@types/electron-devtools-installer": "^2.2.0",
"babel-loader": "^8.0.4",
"css-loader": "^2.0.0",
"electron": "^3.0.10",
"electron-builder": "^20.38.5",
"electron-devtools-installer": "^2.2.4",
"html-webpack-plugin": "^3.2.0",
"node-sass": "^4.11.0",
"react": "^16.6.3",
"react-dom": "^16.6.3",
"redux": "^4.0.1",
"sass-loader": "^7.1.0",
"sqlite3": "^4.0.6",
"standard": "^12.0.1",
"standard-loader": "^6.0.1",
"style-loader": "^0.23.1",
"ts-loader": "^5.3.1",
"tslint": "^5.11.0",
"tslint-config-standard": "^8.0.1",
"tslint-loader": "^3.5.4",
"tslint-webpack-plugin": "^1.3.0",
"typeorm": "^0.2.11",
"typescript": "^3.2.2",
"webpack": "^4.27.1",
"webpack-cli": "^3.1.2"
}
}
And my webpack.config.js
:
const path = require('path')
const HTMLWebpackPlugin = require('html-webpack-plugin');
const commonConfig = {
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js'
},
mode: 'development',
module: {
rules: [
{
test: /\.ts$/,
enforce: 'pre',
loader: 'babel-loader'
},
{
test: /\.tsx?$/,
loader: 'babel-loader'
},
{
test: /\.js$/,
enforce: 'pre',
loader: 'standard-loader'
},
{
test: /\.scss$/,
use: [
{
loader: 'style-loader'
},
{
loader: 'css-loader'
},
{
loader: 'sass-loader'
}
]
}
]
},
node: {
__dirname: false,
__filename: false
},
resolve: {
extensions: ['.js', '.ts', '.tsx', '.jsx', '.json']
}
}
module.exports = [
Object.assign(
{
target: 'electron-main',
entry: { main: './src/main.ts' }
},
commonConfig),
Object.assign(
{
target: 'electron-renderer',
entry: { gui: './src/gui.tsx' },
plugins: [new HTMLWebpackPlugin({
title: 'something',
template: './src/index.html'
})]
},
commonConfig)
]
Any help is appreciated!
Upvotes: 2
Views: 3652
Reputation: 3662
i've got the same issue while i was setting up my project.
To resolve that you can add the following plugin into your webpack config in order to remove the warning for the plugin that you don't want to use
new FilterWarningsPlugin({
exclude: [/mongodb/, /mssql/, /mysql/, /mysql2/, /oracledb/, /redis/, /sqlite3/, /sql.js/, /react-native-sqlite-storage/]
})
Hope that will help you :)
Upvotes: 2