nestjs / ng-universal

Angular Universal module for Nest framework (node.js) 🌷
https://nestjs.com
MIT License
442 stars 68 forks source link

minimal app with "Error: Module parse failed" #911

Closed Sebush closed 1 year ago

Sebush commented 2 years ago

I'm submitting a...


[ ] Regression 
[*] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

i want to install a small angular 14 + @nestjs/ng-universal 6.1 + typeorm app. But there are errors and warnings on start.

./node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:50:23-45 - Warning: Module not found: Error: Can't resolve 'npm' in 'D:\projects\angular\nestjs\myNestJSTest2022\node_modules\@mapbox\node-pre-gyp\lib\util'

./node_modules/@mapbox/node-pre-gyp/lib/util/versioning.js:20:18-65 - Warning: Critical dependency: the request of a dependency is an expression

./node_modules/@nestjs/common/utils/load-package.util.js:16:35-55 - Warning: Critical dependency: the request of a dependency is an expression

./node_modules/@nestjs/core/helpers/load-adapter.js:16:35-59 - Warning: Critical dependency: the request of a dependency is an expression

./node_modules/@nestjs/core/helpers/optional-require.js:10:35-55 - Warning: Critical dependency: the request of a dependency is an expression

./node_modules/app-root-path/lib/app-root-path.js:14:13-59 - Warning: Critical dependency: the request of a dependency is an expression

./node_modules/sqlite3/lib/sqlite3-binding.js:7:16-37 - Warning: Critical dependency: the request of a dependency is an expression

./node_modules/typeorm/connection/ConnectionOptionsReader.js:136:28-47 - Warning: Critical dependency: the request of a dependency is an expression

./node_modules/typeorm/driver/react-native/ReactNativeDriver.js:94:44-82 - Warning: Module not found: Error: Can't resolve 'react-native-sqlite-storage' in 'D:\projects\angular\nestjs\myNestJSTest2022\node_modules\typeorm\driver\react-native'

./node_modules/typeorm/platform/PlatformTools.js:82:17-49 - Warning: Module not found: Error: Can't resolve '@google-cloud/spanner' in 'D:\projects\angular\nestjs\myNestJSTest2022\node_modules\typeorm\platform'

./node_modules/typeorm/platform/PlatformTools.js:89:17-35 - Warning: Module not found: Error: Can't resolve 'mongodb' in 'D:\projects\angular\nestjs\myNestJSTest2022\node_modules\typeorm\platform'

...

./node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html:1:0 - Error: Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <!doctype html>
| <html>
| <head>

./node_modules/node-gyp/lib/Find-VisualStudio.cs:9:6 - Error: Module parse failed: Unexpected token (9:6)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| // This script needs to be compatible with PowerShell v2 to run on Windows 2008R2 and Windows 7.
| 
> using System;
| using System.Text;
| using System.Runtime.InteropServices;

Expected behavior

should work

Minimal reproduction of the problem with instructions

ng new myapp
cd myapp
ng add @nestjs/ng-universal
npm install --save @nestjs/typeorm typeorm sqlite3
npm run dev:ssr

(if TypeOrmModule is in server/app.module.ts imported, there are warnings and errors on start "Error: Module parse failed: Unexpected token...")

What is the motivation / use case for changing the behavior?

Environment


@nestjs/ng-universal      6.1.0
@angular-devkit/architect       0.1402.3
@angular-devkit/build-angular   14.2.3
@angular-devkit/core            14.2.3
@angular-devkit/schematics      14.2.3
@angular/cdk                    14.2.2
@angular/material               14.2.2
@nguniversal/builders           14.2.0
@nguniversal/express-engine     14.0.0
@schematics/angular             14.2.3
rxjs                            7.5.6
typescript                      4.7.4


lucamortellaro commented 1 year ago

Hi,

i have the same problem, with this dependency enviroment:

"@angular/animations": "^16.1.2", "@angular/common": "^16.1.2", "@angular/compiler": "^16.1.2", "@angular/core": "^16.1.2", "@angular/forms": "^16.1.2", "@angular/platform-browser": "^16.1.2", "@angular/platform-browser-dynamic": "^16.1.2", "@angular/platform-server": "^16.1.2", "@angular/router": "^16.1.2", "@nestjs/common": "^10.0.0", "@nestjs/config": "^3.0.0", "@nestjs/core": "^10.0.0", "@nestjs/ng-universal": "^8.0.0", "@nestjs/platform-express": "^10.0.3", "@nestjs/swagger": "^7.0.4", "@nguniversal/express-engine": "^16.1.0", "@ngx-translate/core": "^15.0.0", "@ngx-translate/http-loader": "^8.0.0", "@prisma/client": "^4.16.1", "bcrypt": "^5.1.0", "body-parser": "^1.20.2", "class-transformer": "^0.3.1", "class-validator": "^0.14.0", "express": "^4.15.2", "jsonwebtoken": "^9.0.0", "primeng": "^16.0.2", "reflect-metadata": "^0.1.13", "rxjs": "~7.8.0", "stream-browserify": "^3.0.0", "tslib": "^2.3.0", "util": "^0.12.5", "zone.js": "~0.13.1"

kamilmysliwiec commented 1 year ago

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.