You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I cannot load a simple pojo model due to ES Module restraints
nx serve api-typegoose
> nx run api-typegoose:serve
chunk (runtime: main) main.js (main) 45.5 KiB (javascript) 937 bytes (runtime) [entry] [rendered]
webpack compiled successfully (19b9838b05893a4a)
Debugger listening on ws://localhost:9229/32d4de92-9271-4ed4-8ec0-f7be78c2c19e
Debugger listening on ws://localhost:9229/32d4de92-9271-4ed4-8ec0-f7be78c2c19e
For help, see: https://nodejs.org/en/docs/inspector
Issues checking in progress...
file:///Users/meanstack02/new/starter/dist/apps/api-typegoose/webpack:/starter/external commonjs "@nestjs/core":1
module.exports = require("@nestjs/core");
^
ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/Users/meanstack02/new/starter/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at Object.@nestjs/core (file:///Users/meanstack02/new/starter/dist/apps/api-typegoose/webpack:/starter/external commonjs "@nestjs/core":1:1)
at __webpack_require__ (file:///Users/meanstack02/new/starter/dist/apps/api-typegoose/webpack:/starter/webpack/bootstrap:19:1)
at file:///Users/meanstack02/new/starter/dist/apps/api-typegoose/main.js:1702:70
at file:///Users/meanstack02/new/starter/dist/apps/api-typegoose/main.js:1777:3
at file:///Users/meanstack02/new/starter/dist/apps/api-typegoose/main.js:1782:12
at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
at async Promise.all (index 0)
at ESMLoader.import (node:internal/modules/esm/loader:281:24)
at loadESM (node:internal/process/esm_loader:88:5)
at handleMainPromise (node:internal/modules/run_main:65:12)
No issues found.
If you'd take a moment to look at our pull requests, you'd see there is a PR to support ESM builds. I've been trying to find what the benefit of ESM on the Node + Typescript side of things is, and it's seems that it's really just because ESM is the new standard (which I agree we should try to follow) and because using CJS with ESM is a pain. We'll try to get to this as soon as we can, but I will make no guarantee on how fast that will be.
I tried navigating to your repo and got a GitHub 404, so not sure what's going on there.
Is there an existing issue for this?
Current behavior
I cannot load a simple pojo model due to ES Module restraints
Minimum reproduction code
[email protected]:nhhockeyplayer/starter.git
Steps to reproduce
using latest releases as of 12/2021
just load a simple pojo called Role with name/description
the RoleModule cannot be imported its stopped by the runtime at bootstrap
Expected behavior
RoleModule should load elegantly
Package
@nestjs/common
@nestjs/core
@nestjs/microservices
@nestjs/platform-express
@nestjs/platform-fastify
@nestjs/platform-socket.io
@nestjs/platform-ws
@nestjs/testing
@nestjs/websockets
Other package
No response
NestJS version
No response
Packages versions
{
"type": "module",
"name": "starter",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"typeorm1": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js",
"typeorm2": "typeorm migration:run",
"typeorm3": "typeorm migration:generate -- -n migrationNameHere",
"nx-force-migrate": "if test -f "migrations.json"; then npm run nx migrate -- --run-migrations=migrations.json; fi;",
"large-build": "node --max_old_space_size=16096 ./node_modules/@angular/cli/bin/ng build --aot --prod",
"large-serve": "node --max_old_space_size=16096 ./node_modules/@angular/cli/bin/ng serve --aot --prod",
"ng": "nx",
"mongo-repair": "mongod -config /usr/local/etc/mongod.conf --dbpath ~/data/db --repair",
"mongo-start": "mongod -config /usr/local/etc/mongod.conf --dbpath ~/data/db",
"mongo-stop": "mongo --eval 'use admin, db.shutdownServer()'",
"prewwinstall": "yarn global add json-server",
"prreinstall": "ts-node ./decorate-angular-cli.ts",
"postinstall": "node decorate-angular-cli.cjs && ngcc --properties es2015 browser module main",
"nx": "nx",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "nx workspace-lint && ng lint",
"e2e": "ng e2e",
"affected:apps": "nx affected:apps",
"affected:libs": "nx affected:libs",
"affected:build": "nx affected:build",
"affected:e2e": "nx affected:e2e",
"affected:test": "nx affected:test",
"affected:lint": "nx affected:lint",
"affected:dep-graph": "nx affected:dep-graph",
"affected": "nx affected",
"format": "nx format:write",
"format:write": "nx format:write",
"format:check": "nx format:check",
"update": "nx migrate latest",
"workspace-generator": "nx workspace-generator",
"dep-graph": "nx dep-graph",
"help": "nx help",
"seed:generate": "ts-node typeorm migration:generate -c seed -n ",
"seed:run": "ts-node typeorm migration:run -c seed",
"seed:revert": "ts-node typeorm migration:revert -c seed"
},
"private": true,
"dependencies": {
"@angular/animations": "^13.1.0",
"@angular/cdk": "^13.1.0",
"@angular/common": "^13.1.0",
"@angular/compiler": "^13.1.0",
"@angular/core": "^13.1.0",
"@angular/flex-layout": "^13.0.0-beta.36",
"@angular/forms": "^13.1.0",
"@angular/material": "^13.1.0",
"@angular/platform-browser": "^13.1.0",
"@angular/platform-browser-dynamic": "^13.1.0",
"@angular/router": "^13.1.0",
"@auth0/angular-jwt": "^5.0.2",
"@capacitor/cli": "^3.3.3",
"@capacitor/core": "^3.3.3",
"@fortawesome/angular-fontawesome": "^0.10.1",
"@fortawesome/fontawesome-free": "^5.15.4",
"@fortawesome/fontawesome-svg-core": "^1.2.36",
"@fortawesome/free-brands-svg-icons": "^5.15.4",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@ionic-native/android-permissions": "^5.35.0",
"@ionic-native/app-center-analytics": "^5.35.0",
"@ionic-native/app-center-crashes": "^5.35.0",
"@ionic-native/app-version": "^5.35.0",
"@ionic-native/background-mode": "^5.35.0",
"@ionic-native/call-number": "^5.35.0",
"@ionic-native/core": "^5.35.0",
"@ionic-native/deeplinks": "^5.35.0",
"@ionic-native/document-viewer": "^5.35.0",
"@ionic-native/file": "^5.35.0",
"@ionic-native/file-opener": "^5.35.0",
"@ionic-native/file-path": "^5.35.0",
"@ionic-native/file-transfer": "^5.35.0",
"@ionic-native/fingerprint-aio": "^5.35.0",
"@ionic-native/in-app-browser": "^5.35.0",
"@ionic-native/insomnia": "^5.35.0",
"@ionic-native/local-notifications": "^5.35.0",
"@ionic-native/native-storage": "^5.35.0",
"@ionic-native/network": "^5.35.0",
"@ionic-native/qr-scanner": "^5.35.0",
"@ionic-native/sms-retriever": "^5.35.0",
"@ionic-native/splash-screen": "^5.35.0",
"@ionic-native/status-bar": "^5.35.0",
"@ionic-native/vibration": "^5.35.0",
"@ionic/angular": "^6.0.0",
"@ionic/storage": "^3.0.4",
"@nestifyjs/cookie": "^0.1.0",
"@nestjs/common": "^8.2.3",
"@nestjs/config": "^1.1.5",
"@nestjs/core": "^8.2.3",
"@nestjs/graphql": "^9.1.2",
"@nestjs/jwt": "^8.0.0",
"@nestjs/microservices": "^8.2.3",
"@nestjs/mongoose": "^9.0.1",
"@nestjs/passport": "^8.0.1",
"@nestjs/platform-express": "^8.2.3",
"@nestjs/platform-socket.io": "^8.2.3",
"@nestjs/swagger": "^5.1.5",
"@nestjs/typeorm": "^8.0.2",
"@nestjs/websockets": "^8.2.3",
"@nestjsplus/cookies": "^1.1.1",
"@nestjsx/crud": "^5.0.0-alpha.3",
"@nestjsx/crud-request": "^5.0.0-alpha.3",
"@nestjsx/crud-typeorm": "^5.0.0-alpha.3",
"@ngrx/effects": "^13.0.2",
"@ngrx/entity": "^13.0.2",
"@ngrx/router-store": "^13.0.2",
"@ngrx/schematics": "^13.0.2",
"@ngrx/store": "^13.0.2",
"@ngrx/store-devtools": "^13.0.2",
"@ngx-translate/core": "^14.0.0",
"@ngx-translate/http-loader": "^7.0.0",
"@nrwl/angular": "13.3.1-beta.1",
"@nrwl/schematics": "^8.12.11",
"@nxtend/capacitor": "^12.1.0",
"@nxtend/ionic-angular": "^12.1.0",
"@typegoose/auto-increment": "^1.0.0",
"@typegoose/typegoose": "^9.3.1",
"add": "^2.0.6",
"amazon-cognito-identity-js": "^5.0.6",
"angular-builder-custom-terser-options": "^1.0.1",
"animate.css": "^4.1.1",
"apollo-server-core": "^3.3.0",
"assert": "^2.0.0",
"aws": "0.0.3-2",
"aws-sdk": "^2.688.0",
"bcrypt": "^5.0.1",
"bcrypt-nodejs": "^0.0.3",
"bootstrap": "^5.1.0",
"browser-detect": "^0.2.28",
"chart.js": "^3.5.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.13.2",
"cluster": "^0.7.7",
"config": "^3.3.6",
"cookie-parser": "^1.4.5",
"d3": "^7.0.0",
"d3-array": "^3.0.1",
"d3-brush": "^3.0.0",
"d3-color": "^3.0.1",
"d3-force": "^3.0.0",
"d3-format": "^3.0.1",
"d3-hierarchy": "^3.0.1",
"d3-interpolate": "^3.0.1",
"d3-scale": "^4.0.0",
"d3-selection": "^3.0.0",
"d3-shape": "^3.0.1",
"d3-time-format": "^4.0.0",
"easy-pie-chart": "^2.1.7",
"emoji-flags": "^1.3.0",
"express": "4.17.1",
"font-awesome": "^4.7.0",
"geoip-lite": "^1.4.2",
"global": "^4.4.0",
"graphql": "^16.1.0",
"hammerjs": "^2.0.8",
"hostile": "^1.3.3",
"http-status-codes": "^2.1.4",
"http2": "^3.3.7",
"https": "^1.0.0",
"ionic-plugin-deeplinks": "^1.0.22",
"ionic2-calendar": "^0.6.9",
"ionicons": "^6.0.0",
"jquery": "^3.6.0",
"json2csv": "^5.0.6",
"jsonwebtoken": "^8.5.1",
"jwk-to-pem": "^2.0.5",
"jwt-decode": "^3.1.2",
"koa": "^2.13.1",
"koa-body": "^4.2.0",
"koa-json": "^2.0.2",
"koa-jwt": "^4.0.1",
"koa-passport": "^4.1.4",
"koa-router": "^10.0.0",
"koa-session": "^6.1.0",
"koa-static": "^5.0.0",
"koa2-cors": "^2.0.6",
"lodash": "^4.17.21",
"luxon": "^2.2.0",
"moment": "^2.29.1",
"moment-timezone": "^0.5.33",
"mongoose": "^6.0.14",
"mongoose-autopopulate": "^0.16.0",
"mongoose-findorcreate": "^3.0.0",
"mongoose-lean-virtuals": "^0.9.0",
"nestjs-typegoose": "^7.1.38",
"ng-multiselect-dropdown": "^0.3.7",
"ng2-pdf-viewer": "^7.0.1",
"ngrx-store-freeze": "^0.2.4",
"ngrx-store-logger": "^0.2.4",
"ngx-bootstrap": "^7.0.0",
"ngx-cookie-service": "^13.1.2",
"ngx-doc-viewer": "^2.0.2",
"nodemailer": "^6.6.2",
"passport": "^0.5.0",
"passport-jwt": "^4.0.0",
"passport-local": "^1.0.0",
"pg": "^8.7.1",
"properties-parser": "^0.3.1",
"reflect-metadata": "^0.1.13",
"request": "^2.88.2",
"require": "^2.4.20",
"rimraf": "^3.0.2",
"rxjs": "^7.3.0",
"screenfull": "^6.0.0",
"socket.io": "^4.1.3",
"socket.io-client": "^4.1.3",
"swagger-ui": "^4.1.3",
"swagger-ui-express": "^4.1.6",
"ts-loader": "^9.2.6",
"tslib": "2.3.1",
"typeorm": "^0.2.36",
"zone.js": "0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "^13.1.1",
"@angular-eslint/eslint-plugin": "^13.0.1",
"@angular-eslint/eslint-plugin-template": "^13.0.1",
"@angular-eslint/template-parser": "^13.0.1",
"@angular/cli": "^13.1.1",
"@angular/compiler-cli": "^13.1.0",
"@angular/language-service": "^13.1.0",
"@capacitor/android": "^3.3.3",
"@capacitor/cli": "^3.3.3",
"@capacitor/ios": "^3.3.3",
"@nestjs/schematics": "^8.0.5",
"@nestjs/testing": "^8.2.3",
"@nrwl/cli": "13.3.1-beta.1",
"@nrwl/cypress": "13.3.1-beta.1",
"@nrwl/eslint-plugin-nx": "13.3.1-beta.1",
"@nrwl/express": "13.3.1-beta.1",
"@nrwl/jest": "13.3.1-beta.1",
"@nrwl/linter": "13.3.1-beta.1",
"@nrwl/nest": "13.3.1-beta.1",
"@nrwl/node": "13.3.1-beta.1",
"@nrwl/nx-cloud": "13.0.0",
"@nrwl/tao": "13.3.1-beta.1",
"@nrwl/workspace": "13.3.1-beta.1",
"@nxtend/capacitor": "^12.1.0",
"@types/bcrypt": "^5.0.0",
"@types/bcrypt-nodejs": "^0.0.31",
"@types/bluebird": "^3.5.35",
"@types/bootstrap": "^5.1.0",
"@types/chart.js": "^2.9.32",
"@types/config": "0.0.39",
"@types/d3-array": "^3.0.1",
"@types/d3-axis": "^3.0.1",
"@types/d3-brush": "^3.0.1",
"@types/d3-color": "^3.0.1",
"@types/d3-drag": "^3.0.0",
"@types/d3-force": "^3.0.3",
"@types/d3-format": "^3.0.1",
"@types/d3-hierarchy": "^3.0.2",
"@types/d3-interpolate": "^3.0.1",
"@types/d3-scale": "^4.0.0",
"@types/d3-selection": "^3.0.1",
"@types/d3-selection-multi": "^1.0.10",
"@types/d3-shape": "^3.0.0",
"@types/d3-time": "^3.0.0",
"@types/d3-time-format": "^4.0.0",
"@types/d3-transition": "^3.0.1",
"@types/express": "4.17.0",
"@types/geoip-lite": "^1.4.1",
"@types/googlemaps": "^3.43.3",
"@types/jasmine": "^3.8.2",
"@types/jasminewd2": "^2.0.9",
"@types/jest": "27.0.2",
"@types/jquery": "^3.5.5",
"@types/lodash": "^4.14.172",
"@types/luxon": "^2.0.0",
"@types/moment-timezone": "^0.5.30",
"@types/mongodb": "^4.0.7",
"@types/mongoose": "^5.11.97",
"@types/node": "12.11.1",
"@types/passport-local": "^1.0.33",
"@types/socket.io": "^3.0.2",
"@types/socket.io-client": "^3.0.0",
"@typescript-eslint/eslint-plugin": "5.3.1",
"@typescript-eslint/parser": "5.3.1",
"cypress": "^8.2.0",
"dotenv": "10.0.0",
"eslint": "8.2.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-cypress": "^2.10.3",
"i": "^0.3.7",
"jest": "^27.4.4",
"jest-preset-angular": "11.0.0-rc.3",
"npm": "^8.3.0",
"prettier": "^2.3.1",
"ts-jest": "27.0.5",
"ts-node": "^10.2.0",
"typescript": "4.4.4",
"webpack-sources": "^3.2.2"
},
"resolutions": {
"is-promise": "2.1.0"
}
}
Node.js version
No response
In which operating systems have you tested?
Other
I tried editing the tsconfig's for my api to es2020 without luck
its in a nrwl/nx monorepo
any help is appreciated
I got my angular client side (well everything is housed in a monorepo apps and servers) to build fine using
"type": "module"
in the package.json
The text was updated successfully, but these errors were encountered: