Cannot find module "ngx-gallery" - ASP.NET Core 2 Angular 4 template
See original GitHub issueHi @lukasz-galka ,
When I try to use the library in the new ASP.NET Core 2 Angular template (VS 2017) the module cannot be loaded. The template uses webpack, more specifically:
There is a webpack.config.vendor.js file where you declare the 3rd party libraries. For yours this is the relevant parts;
const nonTreeShakableModules = [
'bootstrap',
'bootstrap/dist/css/bootstrap.css',
'es6-promise',
'es6-shim',
'event-source-polyfill',
'font-awesome/css/font-awesome.css',
'ngx-gallery/lib',
'jquery',
];
const serverBundleConfig = merge(sharedConfig, {
target: 'node',
resolve: { mainFields: ['main'] },
entry: { vendor: allModules.concat(['aspnet-prerendering']) },
output: {
path: path.join(__dirname, 'ClientApp', 'dist'),
libraryTarget: 'commonjs2',
},
module: {
rules: [ { test: /\.css(\?|$)/, use: ['to-string-loader', isDevBuild ? 'css-loader' : 'css-loader?minimize' ] } ]
},
plugins: [
new webpack.DllPlugin({
path: path.join(__dirname, 'ClientApp', 'dist', '[name]-manifest.json'),
name: '[name]_[hash]'
})
],
externals: [nodeExternals({
whitelist: ['/^ngx-gallery/']
})]
});
As you can see I have excluded ngx-gallery but still doesn’t work, I get the following errors (part of them) when I run webpack --progress
ERROR in [at-loader] ./node_modules/ngx-gallery/lib/ngx-gallery-helper.service.ts:29:9
TS2322: Type 'Function[] | undefined' is not assignable to type 'Function[]'.
Type 'undefined' is not assignable to type 'Function[]'.
ERROR in [at-loader] ./node_modules/ngx-gallery/lib/ngx-gallery-preview.component.ts:81:13
TS2322: Type 'number' is not assignable to type 'null'.
ERROR in [at-loader] ./node_modules/ngx-gallery/lib/ngx-gallery-preview.component.ts:96:27
TS2345: Argument of type 'null' is not assignable to parameter of type 'number'.
ERROR in [at-loader] ./node_modules/ngx-gallery/lib/ngx-gallery.component.ts:39:5
TS2322: Type 'undefined' is not assignable to type 'number'.
ERROR in [at-loader] ./node_modules/ngx-gallery/lib/ngx-gallery.component.ts:40:5
TS2322: Type 'undefined' is not assignable to type 'number'.
ERROR in [at-loader] ./node_modules/ngx-gallery/lib/ngx-gallery.component.ts:57:9
TS2322: Type 'number | undefined' is not assignable to type 'number'.
Type 'undefined' is not assignable to type 'number'.
ERROR in [at-loader] ./node_modules/ngx-gallery/lib/ngx-gallery.component.ts:157:9
TS2322: Type '(string | SafeResourceUrl | undefined)[]' is not assignable to type 'string[] | SafeResourceUrl[]'
Type '(string | SafeResourceUrl | undefined)[]' is not assignable to type 'SafeResourceUrl[]'.
Type 'string | SafeResourceUrl | undefined' is not assignable to type 'SafeResourceUrl'.
Type 'undefined' is not assignable to type 'SafeResourceUrl'.
ERROR in [at-loader] ./node_modules/ngx-gallery/lib/ngx-gallery.component.ts:159:9
TS2322: Type '(string | SafeResourceUrl | undefined)[]' is not assignable to type 'string[] | SafeResourceUrl[]'
Type '(string | SafeResourceUrl | undefined)[]' is not assignable to type 'SafeResourceUrl[]'.
ERROR in [at-loader] ./node_modules/ngx-gallery/lib/ngx-gallery.component.ts:160:9
TS2322: Type '(string | undefined)[]' is not assignable to type 'string[]'.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.
......
......
node -v: v6.11.2
Is there anything I can to to fix this?
Thanks
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
How to slove (TS) Cannot find module '@angular/core' in ...
How to slove (TS) Cannot find module '@angular/core' in Visual ... I create Asp.Net Core Project with Angular template. each import row with ......
Read more >ngx-gallery - npm
Responsive Angular 2 / 4 image gallery plugin. Latest version: 5.10.0, last published: 4 years ago. Start using ngx-gallery in your project ...
Read more >Build:cannot find module 'angular2/core' Error - Syncfusion
Hi, First time working with MVC/Syncfusion. I just open the standard MVC template and installed Syncfusion according to the instructions but before even ......
Read more >Google Groups
I am using an asp.net core 2.0 angular template. while deployment I get the following error message when executing the command "webpack --env.prod", ......
Read more >angular/angular - Gitter
C:\ANGULAR-WORKBENCH\test13\project1>npm install typescript@'>=2.4.2 <2.5.0' The system cannot find the file specified.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @chsakell, I will try to fix these errors today
Great work @lukasz-galka , thank you for your quick fix!! I believe we may mark this issue as closed.