My nestjs app starts to blow up pointing to AXIOS_INSTANCE_TOKEN error and request for the module containing AXIOS_INSTANCE_TOKEN to be imported... the thing is the only module using Axios is HttpModule and it was imported from the start. this is what I have:
the error:
] [Nest] 94322 - 02/04/2021, 12:16:31 PM [Genysis Gateway] Start Gateway
[0] [Nest] 94322 - 02/04/2021, 12:16:32 PM [NestFactory] Starting Nest application...
[0] [Nest] 94322 - 02/04/2021, 12:16:32 PM [InstanceLoader] RavenModule dependencies initialized
[0] [Nest] 94322 - 02/04/2021, 12:16:32 PM [InstanceLoader] MsConnectorModule dependencies initialized
[0] [Nest] 94322 - 02/04/2021, 12:16:32 PM [InstanceLoader] ChatModule dependencies initialized
[0] [Nest] 94322 - 02/04/2021, 12:16:32 PM [InstanceLoader] HttpModule dependencies initialized
[0] [Nest] 94322 - 02/04/2021, 12:16:32 PM [InstanceLoader] HttpModule dependencies initialized
[0] [Nest] 94322 - 02/04/2021, 12:16:32 PM [InstanceLoader] HttpModule dependencies initialized
[0] [Nest] 94322 - 02/04/2021, 12:16:32 PM [InstanceLoader] ConfigHostModule dependencies initialized
[0] [Nest] 94322 - 02/04/2021, 12:16:32 PM [ExceptionHandler] Nest can't resolve dependencies of the HttpService (?). Please make sure that the argument AXIOS_INSTANCE_TOKEN at index [0] is available in the AppModule context.
[0]
[0] Potential solutions:
[0] - If AXIOS_INSTANCE_TOKEN is a provider, is it part of the current AppModule?
[0] - If AXIOS_INSTANCE_TOKEN is exported from a separate #Module, is that module imported within AppModule?
[0] #Module({
[0] imports: [ /* the Module containing AXIOS_INSTANCE_TOKEN */ ]
[0] })
THIS IS THE APP MODULE:
......
#Module({
imports: [
RavenModule,
ConfigModule.forRoot({
isGlobal: true,
load: [configuration],
}),
HttpModule.register({
timeout: 5000,
maxRedirects: 5,
}),
AuthModule,
UserModule,
.......
I noticed that the three references to HttpModule initialized ok. Also, I have a check and the two other modules with HttpModules have correctly imported HttpModule in the Module and the injected the HttpService in the Service.
I also noticed that the build died while building ConfigModule...not sure what that means?.... I have also deleted node_modules and run npm I twice and upgrade my nestjs/common from 7.5.1 to 7.6.11 all to no avail.
I would really appreciate any insights on this! Thanks in advance.
Apparently I somehow included HttpService in the app module as a provider and exported it also. Removing both entries resolved the problem.
I had this issue. your appModule is Ok all you need to do is to remove the HttpService from the provider and import HttpModule in order to have HttpService provider available to use.
also see https://docs.nestjs.com/techniques/http-module#getting-started
Related
I tried deploying my React App on Vercel but i get those error messages:
The cli flag --force was set. Skipping build cache download.
Cloning completed: 687.734ms
Running "vercel build"
Vercel CLI 28.4.17
Installing dependencies...
yarn install v1.22.17
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
[2/4] Fetching packages...
error Command failed.
Exit code: 128
Command: git
Arguments: ls-remote --tags --heads ssh://git#github.com/ethereumjs/ethereumjs-abi.git
Directory: /vercel/path0
Output:
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
yarn run v1.22.17
$ next build
info - Loaded env from /vercel/path0/.env
Attention: Next.js now collects completely anonymous telemetry regarding usage.
This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry
info - Linting and checking validity of types...
error - ESLint must be installed in order to run during builds: yarn add --dev eslint
info - Creating an optimized production build...
info - Disabled SWC as replacement for Babel because of custom Babel configuration ".babelrc" https://nextjs.org/docs/messages/swc-disabled
info - Using external babel configuration from /vercel/path0/.babelrc
Failed to compile.
../../usr/local/share/.config/yarn/global/node_modules/next/dist/pages/_document.js
Error: Cannot find module '#babel/preset-react'
Require stack:
- /usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/core.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/telemetry/events/version.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/telemetry/events/index.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/lib/verifyAndLint.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/build/index.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/cli/next-build.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/lib/commands.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/bin/next
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
at Function.mod._resolveFilename (/usr/local/share/.config/yarn/global/node_modules/next/dist/build/webpack/require-hook.js:23:32)
at resolve (node:internal/modules/cjs/helpers:109:19)
at tryRequireResolve (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1:41863)
at resolveStandardizedNameForRequire (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1:42364)
at sync (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1:43011)
at sync (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1910:716601)
at /usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1910:717013
at Generator.next (<anonymous>)
at resolvePreset (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1:40447)
../../usr/local/share/.config/yarn/global/node_modules/next/dist/pages/_error.js
Error: Cannot find module '#babel/preset-react'
Require stack:
- /usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/core.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/telemetry/events/version.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/telemetry/events/index.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/lib/verifyAndLint.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/build/index.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/cli/next-build.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/lib/commands.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/bin/next
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
at Function.mod._resolveFilename (/usr/local/share/.config/yarn/global/node_modules/next/dist/build/webpack/require-hook.js:23:32)
at resolve (node:internal/modules/cjs/helpers:109:19)
at tryRequireResolve (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1:41863)
at resolveStandardizedNameForRequire (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1:42364)
at sync (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1:43011)
at sync (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1910:716601)
at /usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1910:717013
at Generator.next (<anonymous>)
at resolvePreset (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1:40447)
./pages/_app.js
Error: Cannot find module '#babel/preset-react'
Require stack:
- /usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/core.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/telemetry/events/version.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/telemetry/events/index.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/lib/verifyAndLint.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/build/index.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/cli/next-build.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/lib/commands.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/bin/next
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
at Function.mod._resolveFilename (/usr/local/share/.config/yarn/global/node_modules/next/dist/build/webpack/require-hook.js:23:32)
at resolve (node:internal/modules/cjs/helpers:109:19)
at tryRequireResolve (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1:41863)
at resolveStandardizedNameForRequire (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1:42364)
at sync (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1:43011)
at sync (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1910:716601)
at /usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1910:717013
at Generator.next (<anonymous>)
at resolvePreset (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1:40447)
./pages/index.js
Error: Cannot find module '#babel/preset-react'
Require stack:
- /usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/core.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/telemetry/events/version.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/telemetry/events/index.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/lib/verifyAndLint.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/build/index.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/cli/next-build.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/lib/commands.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/bin/next
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
at resolve (node:internal/modules/cjs/helpers:109:19)
at tryRequireResolve (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1:41863)
at resolveStandardizedNameForRequire (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1:42364)
at sync (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1:43011)
at sync (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1910:716601)
at /usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1910:717013
at Generator.next (<anonymous>)
at resolvePreset (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1:40447)
./pages/product/[slug].js
Error: Cannot find module '#babel/preset-react'
Require stack:
- /usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/core.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/telemetry/events/version.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/telemetry/events/index.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/lib/verifyAndLint.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/build/index.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/cli/next-build.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/lib/commands.js
- /usr/local/share/.config/yarn/global/node_modules/next/dist/bin/next
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
at Function.mod._resolveFilename (/usr/local/share/.config/yarn/global/node_modules/next/dist/build/webpack/require-hook.js:23:32)
at resolve (node:internal/modules/cjs/helpers:109:19)
at tryRequireResolve (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1:41863)
at resolveStandardizedNameForRequire (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1:42364)
at sync (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1:43011)
at sync (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1910:716601)
at /usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1910:717013
at Generator.next (<anonymous>)
at resolvePreset (/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/babel/bundle.js:1:40447)
> Build failed because of webpack errors
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Command "yarn run build" exited with 1
I can't deploy on Vercel, any tip on how to fix that?
Thanks in advance.
I'll also leave a link to a video including the full Vercel log with errors highlighted in red: https://www.veed.io/view/218cb302-0a04-406f-84a9-7b5d353a2ffa?sharingWidget=true&panel=share
I tried building and launching the React App on Visual Studio with "yarn run dev" and "yarn run build" and everything works fine, proglems appear while trying to deploy it on Vercel.
After routine update of my server (Debian Sid) I am no longer able to start zero-ui development (actually I'm unable to start any nodejs development server):
zero#zdev:~/zero-ui$ ZU_CONTROLLER_TOKEN=whatever yarnpkg dev
[1] [nodemon] 2.0.15
[1] [nodemon] to restart at any time, enter `rs`
[1] [nodemon] watching path(s): *.*
[1] [nodemon] watching extensions: js,mjs,json
[1] [nodemon] starting `node ./bin/www`
[0] ℹ 「wds」: Project is running at http://192.168.7.122/
[0] ℹ 「wds」: webpack output is served from /app
[0] ℹ 「wds」: Content not from webpack is served from /home/zero/zero-ui/frontend/public
[0] ℹ 「wds」: 404s will fallback to /app/
[0] Starting the development server...
[0]
[0] Error: error:0308010C:digital envelope routines::unsupported
[0] at new Hash (node:internal/crypto/hash:67:19)
[0] at Object.createHash (node:crypto:130:10)
[0] at module.exports (/home/zero/zero-ui/node_modules/webpack/lib/util/createHash.js:135:53)
[0] at NormalModule._initBuildHash (/home/zero/zero-ui/node_modules/webpack/lib/NormalModule.js:417:16)
[0] at handleParseError (/home/zero/zero-ui/node_modules/webpack/lib/NormalModule.js:471:10)
[0] at /home/zero/zero-ui/node_modules/webpack/lib/NormalModule.js:503:5
[0] at /home/zero/zero-ui/node_modules/webpack/lib/NormalModule.js:358:12
[0] at /home/zero/zero-ui/node_modules/loader-runner/lib/LoaderRunner.js:373:3
[0] at iterateNormalLoaders (/home/zero/zero-ui/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
[0] at iterateNormalLoaders (/home/zero/zero-ui/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
[0] /home/zero/zero-ui/node_modules/react-scripts/scripts/start.js:19
[0] throw err;
[0] ^
[0]
[0] Error: error:0308010C:digital envelope routines::unsupported
[0] at new Hash (node:internal/crypto/hash:67:19)
[0] at Object.createHash (node:crypto:130:10)
[0] at module.exports (/home/zero/zero-ui/node_modules/webpack/lib/util/createHash.js:135:53)
[0] at NormalModule._initBuildHash (/home/zero/zero-ui/node_modules/webpack/lib/NormalModule.js:417:16)
[0] at /home/zero/zero-ui/node_modules/webpack/lib/NormalModule.js:452:10
[0] at /home/zero/zero-ui/node_modules/webpack/lib/NormalModule.js:323:13
[0] at /home/zero/zero-ui/node_modules/loader-runner/lib/LoaderRunner.js:367:11
[0] at /home/zero/zero-ui/node_modules/loader-runner/lib/LoaderRunner.js:233:18
[0] at context.callback (/home/zero/zero-ui/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
[0] at /home/zero/zero-ui/node_modules/react-scripts/node_modules/babel-loader/lib/index.js:59:103 {
[0] opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
[0] library: 'digital envelope routines',
[0] reason: 'unsupported',
[0] code: 'ERR_OSSL_EVP_UNSUPPORTED'
[0] }
[0] cd frontend && cross-env FAST_REFRESH=true yarn start exited with code 1
Note this does not seem to be the same problem I found discussed here and elsewhere on the internet (breaking change in node v16->v17) as I currently have:
zero#zdev:~/zero-ui$ node --version
v16.15.0
Note: I tried nonetheless adding NODE_OPTIONS=--openssl-legacy-provider to my options but this, rather unsurprisingly, does not work (/usr/bin/node: --openssl-legacy-provider is not allowed in NODE_OPTIONS which I take it means this option was added in v17 and is useless before the breaking change).
I strongly suspect some update in my debian sid is responsible, but I'm unable to understand which.
Note also this is specific to current Debian Sid: It is reproducible on a brand new install (using containers) and will not appear doing the exact same install on Debian Bookworm.
How can I overcome this?
TiA!
I have the sam problem. I've upgraded node.js to 17.7.2 and run into this error. Then upgraded to 18.4 and still got the error. Then using the legacy option - without success. Then downgraded node.js to 16.15.1, tried to up- and downgrade the webpack (4.46 => 5.63 => 4.46) but I got still the error. Even an uninstallation of node.js, removing all the cache folders and a brand new installation of node.js hadn't helped.
What I absolutely don't understand is, that the last line after the error message is "Node.js v17.7.2" which is definitely NOT on my system.
node:internal/crypto/hash:67
this[kHandle] = new _Hash(algorithm, xofLen);
^
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at Object.createHash (node:crypto:135:10)
at module.exports (C:\Users\pauly\repos\sources\dev\nuxt\test-app\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (C:\Users\pauly\repos\sources\dev\nuxt\test-app\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (C:\Users\pauly\repos\sources\dev\nuxt\test-app\node_modules\webpack\lib\NormalModule.js:471:10)
at C:\Users\pauly\repos\sources\dev\nuxt\test-app\node_modules\webpack\lib\NormalModule.js:503:5
at C:\Users\pauly\repos\sources\dev\nuxt\test-app\node_modules\webpack\lib\NormalModule.js:358:12
at C:\Users\pauly\repos\sources\dev\nuxt\test-app\node_modules\webpack\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (C:\Users\pauly\repos\sources\dev\nuxt\test-app\node_modules\webpack\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at Array.<anonymous> (C:\Users\pauly\repos\sources\dev\nuxt\test-app\node_modules\webpack\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
at Storage.finished (C:\Users\pauly\repos\sources\dev\nuxt\test-app\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
at C:\Users\pauly\repos\sources\dev\nuxt\test-app\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
at C:\Users\pauly\repos\sources\dev\nuxt\test-app\node_modules\graceful-fs\graceful-fs.js:123:16
at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
Node.js v17.7.2
This whole issue started with "npx create-nuxt-app", simply that - as I tried to create my nuxt application. What a mess.
I created a migration for an entity in Mikro Orm. After that, i modified the entity and ran the migrations again. Now nestjs keeps giving me this error.
This was my entity.
#Entity()
export class Task extends BaseEntity<Task, 'id'> {
#PrimaryKey()
id: number;
#Property()
name: string;
#Property()
description: string;
}
I created initial migration with npx mikro-orm migration:create --initial. After that i modified my entity to this:
#Entity()
export class Task extends BaseEntity<Task, 'id'> {
#PrimaryKey()
id: number;
#Property()
name: string;
#Property()
description: string;
#Enum(() => TaskStatus)
status: TaskStatus = TaskStatus.OPEN;
}
export enum TaskStatus {
OPEN = 'OPEN',
IN_PROGRESS = 'IN_PROGRESS',
DONE = 'DONE',
}
After that, I ran two commands npx mikro-orm migration:create & npx mikro-orm migration:up.
Now NestJs keeps giving me this error.
[Nest] 13528 - 02/06/2021, 6:59:14 pm [NestFactory] Starting Nest application...
[Nest] 13528 - 02/06/2021, 6:59:14 pm [InstanceLoader] MikroOrmModule dependencies initialized +43ms
[Nest] 13528 - 02/06/2021, 6:59:14 pm [InstanceLoader] ConfigHostModule dependencies initialized +1ms
[Nest] 13528 - 02/06/2021, 6:59:14 pm [InstanceLoader] AppModule dependencies initialized +1ms
[Nest] 13528 - 02/06/2021, 6:59:14 pm [InstanceLoader] ConfigModule dependencies initialized +0ms
[Nest] 13528 - 02/06/2021, 6:59:14 pm [ExceptionHandler] Duplicate entity names are not allowed: Task +409ms
MetadataError: Duplicate entity names are not allowed: Task
at Function.duplicateEntityDiscovered (C:\dev\nodejs\nestjs\sandbox\node_modules\#mikro-orm\core\errors.js:151:16) at MetadataValidator.validateDiscovered (C:\dev\nodejs\nestjs\sandbox\node_modules\#mikro-orm\core\metadata\MetadataValidator.js:40:42)
at MetadataDiscovery.findEntities (C:\dev\nodejs\nestjs\sandbox\node_modules\#mikro-orm\core\metadata\MetadataDiscovery.js:81:24)
at processTicksAndRejections (node:internal/process/task_queues:93:5)
at async MetadataDiscovery.discover (C:\dev\nodejs\nestjs\sandbox\node_modules\#mikro-orm\core\metadata\MetadataDiscovery.js:34:9)
at async Function.init (C:\dev\nodejs\nestjs\sandbox\node_modules\#mikro-orm\core\MikroORM.js:42:24)
at async Injector.instantiateClass (C:\dev\nodejs\nestjs\sandbox\node_modules\#nestjs\core\injector\injector.js:290:37)
at async callback (C:\dev\nodejs\nestjs\sandbox\node_modules\#nestjs\core\injector\injector.js:42:30)
at async Injector.resolveConstructorParams (C:\dev\nodejs\nestjs\sandbox\node_modules\#nestjs\core\injector\injector.js:114:24)
at async Injector.loadInstance (C:\dev\nodejs\nestjs\sandbox\node_modules\#nestjs\core\injector\injector.js:46:9)
I also had this issue and I knew I didn't have a duplicate model name. The problem occurred after I had moved a model to a different directory.
The resolution was to clear the dist build folder and the temp metadata folders.
UPDATE
After investigation, the code can be run perfectly. There maybe some problems on the node_modules where some incomplete/incompatible packages exist.
The solution is to remove node_modules and reinstall again.
The steps you do is the following:
create a Task class
create migration file
modify the Task class
create migration file again
do the migration
If you modify the Task class without running migration command before, you will end up having 2 migration files with create task table command because mikro does not have any references of task table before any migration happened.
You can check the SQL in both migration files, it should be create table task xxx.
Therefore, there is a way to solve it:
delete the 2nd migration file first
run npx mikro-orm migration:up to create task table on DB without enum
run npx mikro-orm migration:create.
Right now, mikro has references of the task table and know that you want to alter table so the SQL in migration will be alter table task instead of create table
run npx mikro-orm migration:up to alter task table on DB with enum
When I try to install NestJs application on IIS-server (with iisnode installed) I always just encounter issue which says
"...Error: listen EADDRINUSE: address already in use :::3450.." (see below)
And, as you can see from the console.log (see below), the NestJs application is first fully initialized and launched, but then comes always the port already in use issue. And it persists no matter how many different ports I try. I have also tried to restart iisnode.exe and killed the process and the port but it does not help. Anyone any experience with this and found the solution?
node dist/main
[32m[Nest] 36096 - [39m09/01/2020, 1:43:54 PM [33m[NestFactory] [39m[32mStarting Nest application...[39m
[32m[Nest] 36096 - [39m09/01/2020, 1:43:54 PM [33m[InstanceLoader] [39m[32mConfigHostModule dependencies initialized[39m[33m +34ms[39m
[32m[Nest] 36096 - [39m09/01/2020, 1:43:54 PM [33m[InstanceLoader] [39m[32mAppModule dependencies initialized[39m[33m +0ms[39m
[32m[Nest] 36096 - [39m09/01/2020, 1:43:54 PM [33m[InstanceLoader] [39m[32mConfigModule dependencies initialized[39m[33m +1ms[39m
hello from NestJs app
[32m[Nest] 36096 - [39m09/01/2020, 1:43:54 PM [33m[RoutesResolver] [39m[32mAppController {}:[39m[33m +13ms[39m
[32m[Nest] 36096 - [39m09/01/2020, 1:43:54 PM [33m[RouterExplorer] [39m[32mMapped {, GET} route[39m[33m +4ms[39m
[32m[Nest] 36096 - [39m09/01/2020, 1:43:54 PM [33m[RoutesResolver] [39m[32mItemsController {/items}:[39m[33m +0ms[39m
[32m[Nest] 36096 - [39m09/01/2020, 1:43:54 PM [33m[RouterExplorer] [39m[32mMapped {/items, GET} route[39m[33m +1ms[39m
[32m[Nest] 36096 - [39m09/01/2020, 1:43:54 PM [33m[RouterExplorer] [39m[32mMapped {/items/:id, GET} route[39m[33m +2ms[39m
[32m[Nest] 36096 - [39m09/01/2020, 1:43:54 PM [33m[RouterExplorer] [39m[32mMapped {/items, POST} route[39m[33m +1ms[39m
[32m[Nest] 36096 - [39m09/01/2020, 1:43:54 PM [33m[RoutesResolver] [39m[32mShoppingCartController {/shopping-cart}:[39m[33m +1ms[39m
[32m[Nest] 36096 - [39m09/01/2020, 1:43:54 PM [33m[RouterExplorer] [39m[32mMapped {/shopping-cart, POST} route[39m[33m +0ms[39m
[32m[Nest] 36096 - [39m09/01/2020, 1:43:54 PM [33m[NestApplication] [39m[32mNest application successfully started[39m[33m +4ms[39m
App is running in port: 61302
events.js:292
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::61302
at Server.setupListenHandle [as _listen2] (net.js:1313:16)
at listenInCluster (net.js:1361:12)
at Server.listen (net.js:1447:7)
at ExpressAdapter.listen (C:\...\node_modules\#nestjs\platform-express\adapters\express-adapter.js:45:32)
at NestApplication.listen (C:\...\node_modules\#nestjs\core\nest-application.js:146:26)
at async bootstrap (C:\...\dist\main.js:8:9)
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1340:8)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
code: 'EADDRINUSE',
errno: 'EADDRINUSE',
syscall: 'listen',
address: '::',
port: 61302
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nest-restaurant-api#0.0.1 start:prod: `node dist/main`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nest-restaurant-api#0.0.1 start:prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\...\AppData\Roaming\npm-cache\_logs\2020-09-01T12_43_54_285Z-debug.log
In iisnode server error log I can also find the following:
(this proved to be logged in previous day - and not to be seen anymore in the logs. So, this iisnode log message may not be relevant for the issue at all)
(node:45472) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(node:45472) UnhandledPromiseRejectionWarning: RangeError [ERR_SOCKET_BAD_PORT]: options.port should be >= 0 and < 65536. Received NaN.
at validatePort (internal/validators.js:182:11)
at Server.listen (net.js:1439:5)
at ExpressAdapter.listen (C:\...\node_modules\#nestjs\platform-express\adapters\express-adapter.js:45:32)
at NestApplication.listen (C:\...\node_modules\#nestjs\core\nest-application.js:146:26)
at async bootstrap (C:\...\dist\main.js:7:5)
(node:45472) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:45472) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
In addition here is the /dist/main.js file in its present form (I have added those try / catch -statements).
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("#nestjs/core");
const app_module_1 = require("./app.module");
async function bootstrap() {
try {
const app = await core_1.NestFactory.create(app_module_1.AppModule);
await app.listen(parseInt(process.env.PORT) || 8080)
.catch((e) => {
console.error(e);
process.exit(1);
});
console.log('App is running in port: ' + process.env.PORT);
}
catch (error) {
console.log("Error message: " + error);
}
}
bootstrap().catch(e => {
console.error(e);
});
//# sourceMappingURL=main.js.map
As suggested by Bruce Zhang in his comment I will post the solution I found by myself.
So, the cause of the error was quite silly indeed.
1.) Using Plesk controlling panel (in IIS-server), irrespective of whether the NestJs application is deployed to site root or sub folder (like the default dist folder ), it is essential to get path settings to project to refer correctly:
Now, in the image above, path settings to project are correct when deployed to sub folder (i.e. default build folder dist). My error was that path reference for the Application Startup File was "/dist/main.js" as it should be just main.js.
After this simple correction app started normally with default IIS-port (port 80 and for SSL-protected connection 443). The main.ts -file does not have to anything else than just the following with the IIS default port fetched automatically via process.env.PORT:
import { NestFactory } from '#nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(process.env.PORT);
}
bootstrap();
2.) The second simple thing that must be correctly configured is web.config (and this was originally correct in my case):
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="dist/main.js" verb="*" modules="iisnode" />
</handlers>
<iisnode nodeProcessCommandLine="C:\Program Files\nodejs\node.exe">
</iisnode>
<rewrite>
<rules>
<rule name="nestjs">
<match url="/*" />
<action type="Rewrite" url="main.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I hope this help those who might get confused with IISnode settings in Plesk. And these settings apply generally to all Node.js applications, they are not limited to NestJs which is just upper level framework on node.js, and particularly much on Express. But error messages in IISNode can sometimes be a bit misleading and it takes some pain to see through them.
NestJs is really awesome and it is great that those who have to, or love to, use IIS can easily deploy super modern NestJs backend apps to IIS-server, thanks to those who implemented IISnode.
I just followed the documentation and attached prisma to my nest project. The problem is, when I run yarn start:dev it populates the graphql.options.ts with some unknown schema and throws the following error:
[nodemon] starting `ts-node -r tsconfig-paths/register src/main.ts`
[Nest] 50392 - 12/24/2018, 10:08:57 PM [NestFactory] Starting Nest application...
[Nest] 50392 - 12/24/2018, 10:08:57 PM [InstanceLoader] AppModule dependencies initialized +43ms
[Nest] 50392 - 12/24/2018, 10:08:57 PM [InstanceLoader] PrismaModule dependencies initialized +0ms
[Nest] 50392 - 12/24/2018, 10:08:57 PM [InstanceLoader] UsersModule dependencies initialized +1ms
[Nest] 50392 - 12/24/2018, 10:08:57 PM [InstanceLoader] GraphQLModule dependencies initialized +0ms
(node:50392) UnhandledPromiseRejectionWarning: Error: Interface field Vehicle.wheels expects type Int but Car.wheels is type String.
Interface field argument Vehicle.stuff(a:) expects type Int but Car.stuff(a:) is type String.
at assertValidSchema (/Users/pubudu/Projects/nest-prisma-sample/node_modules/graphql/type/validate.js:71:11)
at assertValidExecutionArguments (/Users/pubudu/Projects/nest-prisma-sample/node_modules/graphql/execution/execute.js:146:35)
at executeImpl (/Users/pubudu/Projects/nest-prisma-sample/node_modules/graphql/execution/execute.js:67:3)
at Object.execute (/Users/pubudu/Projects/nest-prisma-sample/node_modules/graphql/execution/execute.js:62:229)
at Object.generateSchemaHash (/Users/pubudu/Projects/nest-prisma-sample/node_modules/apollo-server-core/src/utils/schemaHash.ts:11:18)
at new ApolloServerBase (/Users/pubudu/Projects/nest-prisma-sample/node_modules/apollo-server-core/src/ApolloServer.ts:299:23)
at new ApolloServer (/Users/pubudu/Projects/nest-prisma-sample/node_modules/apollo-server-express/src/ApolloServer.ts:70:1)
at GraphQLModule.<anonymous> (/Users/pubudu/Projects/nest-prisma-sample/node_modules/#nestjs/graphql/dist/graphql.module.js:118:33)
at Generator.next (<anonymous>)
at fulfilled (/Users/pubudu/Projects/nest-prisma-sample/node_modules/#nestjs/graphql/dist/graphql.module.js:16:58)
(node:50392) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:50392) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Here's the sample code:
https://github.com/THPubs/nest-prisma-sample
Any idea what's happening?
The issues is with the GraphQLOptions. In there, according to the examples, I have defined the typePaths as follows:
typePaths: ['./**/*.graphql'],
It looks like this gets all the graphql files in the project even from the node_modules folder. So, to import exactly the file I want, I used the following:
typePaths: ['./src/prisma/prisma-types.graphql'],