I am new to NESTJS and keep getting this error:
[Nest] 26563 - 16/08/2022 09:25:22 ERROR [ExceptionHandler] Nest can't resolve dependencies of the EmailConfirmationController (?). Please make sure that the argument EmailConfirmationService at index [0] is available in the EmailConfirmationModule context.
link to my repository: https://github.dev/GuilhermeVozniak/CP
In your EmailConfirmationController make sure you are using import { EmailConfirmationService } from './email-confirmation.service' instead of import { EmailConfirmationService } from './email-Confirmation.service'. File name is important here. I tried cloning your repo and it failed on Linux.
Related
Background
I'm creating an application that allows users to interact with basic web controls which output controller events through emulated virtual controllers (so user slides a slider, and that manifests in the system as an axis being changed on a virtual controller). I'm building this as an Electron app which contains an Angular CLI project.
To get the virtual controller functionality I'm consuming a project which wraps native virtual controller functionality and exposes it for node applications. (node-ViGEmClient)
Issue
I've created the basic project and imported the required package. However, when I build the project with ng-build I get the following errors:
./node_modules/vigemclient/lib/DS4Controller.js:1:20-59 - Error: Module not found: Error: Can't resolve '../build/Release/vigemclient' in 'C:\Develop\WebDev\Node\deskpad\node_modules\vigemclient\lib'
Tracking these errors down, they come from files like this:
Looking further into the package's structure, it should be looking for vigemclient.node in build/Release, and that file is indeed present:
I feel like there is some configuration I need to do in Angular (something to do with webpack?) but I don't know what it is. Can anyone point me in the right direction?
In case anyone wants to poke around with my (currently barebones) project, it's located here: DeskPad
Project Details
Node: v16.17.0
Angular CLI: v14.2.3
REPRODUCING
Create a new Angular CLI project:
ng new testProj
Install ViGEmClient package:
npm install vigemclient
Note: This seems to require libraries related to building C++ code which are prompted during the initial install for Node.
Add this line to tsconfig.json to allow synthetic default imports:
"allowSyntheticDefaultImports": true,
Reference the package in the default app component so that it is used:
import { Component } from '#angular/core';
import ViGEmClient from 'vigemclient';
#Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'vigTestAngular';
client = new ViGEmClient();
}
Attempt to build the project with the command "npm run build"
Outcome: These errors should be produced:
./node_modules/vigemclient/lib/DS4Controller.js:1:20-59 - Error: Module not found: Error: Can't resolve '../build/Release/vigemclient' in 'C:\Develop\WebDev\Node\vigTestAngular\node_modules\vigemclient\lib'
./node_modules/vigemclient/lib/ViGEmClient.js:1:20-59 - Error: Module not found: Error: Can't resolve '../build/Release/vigemclient' in 'C:\Develop\WebDev\Node\vigTestAngular\node_modules\vigemclient\lib'
./node_modules/vigemclient/lib/ViGEmTarget.js:5:20-59 - Error: Module not found: Error: Can't resolve '../build/Release/vigemclient' in 'C:\Develop\WebDev\Node\vigTestAngular\node_modules\vigemclient\lib'
./node_modules/vigemclient/lib/X360Controller.js:1:20-59 - Error: Module not found: Error: Can't resolve '../build/Release/vigemclient' in 'C:\Develop\WebDev\Node\vigTestAngular\node_modules\vigemclient\lib'
I was experiencing the exact same error with a native package. In my case this is also an Electron app with angular ~14.2 on Windows.
A friend pointed me to the problem: I was importing the native package from the angular web app code (renderer), but apparently when using native packages in an Electron application, they can only be imported in the Electron main process (main.ts).
Hope this helps!
In NestJs and Vendure application, if I add plugins to vendure-config, If I add any plugins, it's giving error. I tried to add ElasticSearch Plugin as mentioned here in the official documentation.
I'm getting following error when I run the project:
Nest can't resolve dependencies of the ConfigModule (ConfigService, ?). Please make sure that the argument ModuleRef at index [1] is available in the ConfigModule context.
Potential solutions:
- If ModuleRef is a provider, is it part of the current ConfigModule?
- If ModuleRef is exported from a separate #Module, is that module imported within ConfigModule?
#Module({
imports: [ /* the Module containing ModuleRef */ ]
})
Error: Nest can't resolve dependencies of the ConfigModule (ConfigService, ?). Please make sure that the argument ModuleRef at index [1] is available in the ConfigModule context.
I tried to add ElasticsearchPlugin to imports: [ElasticsearchPlugin] in ConfigModule. But still I'm getting the same issue.
Could anyone please help me on this?
Thanks in Advance.
This is what I tried to resolve:
I followed this to integrate the plugin.
Then, after getting the issue, I tried to add imports: [ElasticsearchPlugin] in ConfigModule and AppModule.
Then, the error is still same, So, I tried to add the ElasticsearchPlugin to imports, exports and providers array. Still the same issue.
I have some helper functions inside the /src/common/helper/cash.helper.ts. When I call this function from a module, I get the following error.
Error: Cannot find module './../../../src/common/helper/cast.helper' Require stack:
However, the e2e tests are working without any problem. Here, you can see the folder structure.
When I change the import to absolute path import { toNumber } from 'src/common/helper/cast.helper'; It's working, but the e2e tests are not working.
What's wrong here? How can I use common functions and constants across all the modules in NestJS?
I did the following to fix the issue.
I changed the import to absolute path import { toNumber } from 'src/common/helper/cast.helper';
To fix the e2e test, I have added "moduleDirectories": ["<rootDir>/../", "node_modules"] to the jest-e2e.json.
I am trying to create a web-page using nodeJS and nextJS that stores documents on google drive. For this I installed the NPM module "googleapis" but when I import this module in my particular JS file it throws an error as mentioned below,
./node_modules/google-auth-library/build/src/auth/googleauth.js:17:0
Module not found: Can't resolve 'child_process'
Import trace for requested module:
./node_modules/google-auth-library/build/src/index.js
./node_modules/googleapis/build/src/index.js
To solve this error I have tried the below solution and this method resolved my issue, I have added this below solution in next.config.js
webpack: (config, { isServer }) => {
if (!isServer) {
config.resolve.fallback = {
fs: false,
path: false,
child_process: false,
}
}
return config
},
This solution solved my issue but throws another error as mentioned below,
./node_modules/googleapis-common/build/src/http2.js:16:0
Module not found: Can't resolve 'http2'
Did you mean './http2'?
Requests that should resolve in the current directory need to start with './'.
Requests that start with a name are treated as module requests and resolve within module directories (node_modules).
If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
Import trace for requested module:
./node_modules/googleapis-common/build/src/apirequest.js
./node_modules/googleapis-common/build/src/index.js
./node_modules/googleapis/build/src/index.js
This http2 module is deprecated by NPM.
How to resolve this http2 module issue or does anyone know that how to tackle this child_process issue?
I am following Josh Morony's tutorial with the following URL.
https://www.joshmorony.com/creating-role-based-authentication-with-passport-in-ionic-2-part-1/
https://www.joshmorony.com/creating-role-based-authentication-with-passport-in-ionic-2-part-2/
The published date is not too old as it was published in Jan 2018. Unfortunately, I can't get it running. Too much errors. Can someone provide a working code for me to learn ? Some of the code is also invalid in some point which I managed to fix. But I still cannot get it running. Hope that you can help.
After I followed the tutorial below
https://www.joshmorony.com/creating-role-based-authentication-with-passport-in-ionic-2-part-2/
I ran the command ionic serve to test out the application, there I received the following error
Typescript Error
Cannot find module 'ionic-native'.
...Application/Development/Cordova/josh1/client/todo->roles/src/app/app.component.ts
import { Platform } from 'ionic-angular';
import { StatusBar } from 'ionic-native';
I checked online and found out that I need to replace
import { StatusBar } from 'ionic-native';
with
import { StatusBar } from '#ionic-native/status-bar';
After I changed it, i received the following error,
Property 'styleDefault' does not exist on type 'BarProp'.
..Application/Development/Cordova/josh1/client/todo->roles/src/app/app.component.ts
statusbar.styleDefault();
});
The solution to it is that i need to comment out statusbar.styleDefault();
The last ionic serve command I ran shows the following error :
Runtime Error
Can't resolve all parameters for Storage: (?)
Stack
Error: Can't resolve all parameters for Storage: (?).
at syntaxError (http://localhost:8100/build/vendor.js:80025:34)
at CompileMetadataResolver._getDependenciesMetadata (http://localhost:8100/build/vendor.js:95245:35)
at CompileMetadataResolver._getTypeMetadata (http://localhost:8100/build/vendor.js:95080:26)
at CompileMetadataResolver._getInjectableMetadata (http://localhost:8100/build/vendor.js:95060:21)
at CompileMetadataResolver.getProviderMetadata (http://localhost:8100/build/vendor.js:95420:40)
at http://localhost:8100/build/vendor.js:95331:49
at Array.forEach ()
at CompileMetadataResolver._getProvidersMetadata (http://localhost:8100/build/vendor.js:95291:19)
at CompileMetadataResolver.getNgModuleMetadata (http://localhost:8100/build/vendor.js:94859:50)
at JitCompiler._loadModules (http://localhost:8100/build/vendor.js:113952:87)
I am really lost here. No other meaningful error description provided. If you have tried the following tutorial, can you provide some assistance ?