I am using NEST.JS framework and want to add external plugin New Relic Apollo Server plugin.
apollo-server-fastify: "^2.19.2"
#newrelic/apollo-server-plugin: "^0.1.2"
import { apolloServerNewRelicPlugin } from '#newrelic/apollo-server-plugin';
GraphQLModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
....
plugins: [apolloServerNewRelicPlugin],
}),
When I start server for e2e test it required real NewRelic key ; is there a way to start for test environment without requiring real key ?
To test out things I started server with real key; Missing Key and cannot start agent error disappeared but below is the error I am seeing
UnhandledPromiseRejectionWarning: TypeError: Cannot use 'in' operator to search for '__internal_plugin_id__' in undefined
my-application | at Object.pluginIsInternal (/usr/src/app/node_modules/apollo-server-fastify/node_modules/apollo-server-core/dist/plugin/internalPlugin.js:5:37)
Update: the plugin has been updated and it supports TypeScript now.
I've had the same error initially. The way I made it work here was to create a typings/newrelic-apollo-server-plugin/index.ts file containing a module declaration:
declare module '#newrelic/apollo-server-plugin'
Then, in my NestJS module file:
import apolloServerNewRelicPlugin from '#newrelic/apollo-server-plugin'
#Module({
imports: [
...
GraphQLModule.forRoot({
...
plugins: [apolloServerNewRelicPlugin],
}),
Related
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 upgraded jest from version 27 to version 29.
Since then, some indirect file resolve do not work anymore.
Here is my config:
module.exports = {
roots: ['app/javascript/__tests__/'],
testMatch: ['**/?(*.)(spec|test).js?(x)'],
testEnvironment: 'jsdom',
testRunner: 'jest-jasmine2',
moduleDirectories: [
'node_modules',
'app/javascript',
'app/javascript/__tests__'
],
transform: {
'^.+\\.jsx?$': 'babel-jest'
},
moduleNameMapper: {
'^.+\\.(svg)$': '<rootDir>/app/javascript/__tests__/fileMock.js'
},
setupFiles: ['./app/javascript/__tests__/setup.jsx']
}
There is a file in my code base, let's say app/javascript/MyReactComponent.jsx, which is imported as part of my tested component, and that contains the following import line:
// app/javascript/MyReactComponent.jsx
import 'firebase/init'
Expected behavior
Until today, I could run jest, and it was finding all my code as expected, inclluding the above import, which is located here:
app/javascript/firebase/init.js
Error
Instead, running jest throws the following error.
Cannot find module 'firebase/init' from 'app/javascript/MyReactComponent.jsx'
FWIW, I have traced the resolver code up to the default jest resolver, and it seems like it tries to get the file from within the firebase node module, instead of fetching the init.js file in the firebase directory.
Question
Is there a way to adjust my configuration in order for the resolver to find my file?
Have you tried adding an entry for that aliased module in moduleNameMapper?
moduleNameMapper: {
'^.+\\.(svg)$': '<rootDir>/app/javascript/__tests__/fileMock.js',
'^firebase/init': '<rootDir>/app/javascript/firebase/init.js'
}
I went back to a small project after a month. I updated nestjs and npm but the app don't start. I reverted it and it works well. On the initialization of the project (npm run start), it stops at : "[Nest] 13012 - 2019-06-15 16:01 [InstanceLoader] TypeOrmModule dependencies initialized +1ms" and don't go further.
Here is the link for my repo : https://github.com/Ithrandil/coffeeshareBE
I really don't know what to try and did'nt found any specific bug report on Nestjs repo.
I've went from the 6.0.0 to the 6.3.1 version on nestJs.
Here is the different updates :
#types/express#4.17.0
prettier#1.18.2
nodemon#1.19.1
#types/node#10.14.9
typeorm#0.2.18
swagger-ui-express#4.0.6
#nestjs/platform-express#6.3.1
rxjs#6.5.2
#nestjs/core#6.3.1
#nestjs/typeorm#6.1.2
#nestjs/testing#6.3.1
typescript#3.5.2
#nestjs/common#6.3.1
class-transformer#0.2.3
It looks like the issue is with the way you're injecting the custom repository UserRepository.
First, in your user repository, delete the constructor, and change the class declaration to look like this:
#EntityRepository(User)
export class UserRepository extends Repository<User> {
Then, in your user module, change your module to look like this:
#Module({
imports: [TypeOrmModule.forFeature([User, UserRepository])],
controllers: [UserController],
providers: [UserService],
exports: [],
})
export class UserModule {}
Then, in your user service, change your constructor to inject the repository like this:
constructor(
#InjectRepository(UserRepository)
private readonly userRepo: UserRepository,
) {}
For more information, here is a related issue I found:
https://github.com/nestjs/typeorm/issues/44
You don't have TypeOrm dependency declared in your package.json, are you using this ORM with Nest? If so you need to specify it via yarn or npm and it will be added as dependency in your package.json file.
For instance, add the dependency of TypeOrm in your deps:
"typeorm": "^0.2.18"
And see if it solves everything or just brings to another problem.
Does server-side rendering with react-loadable work with Webpack 4 and Babel 7? I've been unable to get it working successfully while following the instructions.
After following just the client-side steps, Webpack correctly outputs separate chunks for each loadable component and this is reflected when I load the page in the browser (ie: the chunks are lazy-loaded).
After following all the SSR steps, however, the server throws the following error:
Error: Not supported
at loader (/Projects/test-project/web/routes/index.js:50:15)
at load (/Projects/test-project/web/node_modules/react-loadable/lib/index.js:28:17)
at init (/Projects/test-project/web/node_modules/react-loadable/lib/index.js:121:13)
at flushInitializers (/Projects/test-project//web/node_modules/react-loadable/lib/index.js:310:19)
at /Projects/test-project/web/node_modules/react-loadable/lib/index.js:322:5
at new Promise (<anonymous>)
at Function.Loadable.preloadAll (/Projects/test-project/web/node_modules/react-loadable/lib/index.js:321:10)
at Object.preloadAll (/Projects/test-project/web/server.js:15:10)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Module._compile (/Projects/test-project/web/node_modules/pirates/lib/index.js:83:24)
My routes/index.js file:
import React from 'react';
import Loadable from 'react-loadable';
import Loading from '../components/Loading';
export default [
{
path: '/',
component: Loadable({
loader: () => import('./controllers/IndexController'),
loading: Loading,
}),
exact: true,
},
{
path: '/home',
component: Loadable({
loader: () => import('./controllers/HomeController'),
loading: Loading,
}),
exact: true,
},
...
];
This issue on SO is possibly related to the server error I'm seeing above, but provided even less info.
My .babelrc is already using #babel/plugin-syntax-dynamic-import, but I tried adding babel-plugin-dynamic-import-node. This fixes the server issue but Webpack then no longer builds the chunks.
I've been unable to find a definitive example to get this working. There is conflicting info out there about proper setup. For example, the react-loadable README says to use the included react-loadable/babel plugin, while this post by the lib author says to use babel-plugin-import-inspector. This PR seemed to be attempting to address Webpack 4 issues but was closed, and the forked lib appeared to have issues as well.
I am using:
Babel 7
Node 10.4
React 16.5
React-Loadable 5.5
Webpack 4
I had the exact same problem today. After adding dynamic-import-node to the plugins of my .babelrc the server worked, but webpack wasn't creating the chunks. I then removed it again from my .babelrc and moved it to my server script with #babel/register. My server script now looks like this:
require( "#babel/register" )({
presets: ["#babel/preset-env", "#babel/preset-react"],
plugins: ["dynamic-import-node"]
});
require( "./src/server" );
I hope this helps ;)
I just wanted to setup my vue project with the full webpack template, use vue router and link different urls to different components.
The src/router/index.html is the following:
import Vue from 'vue';
import Router from 'vue-router';
// eslint-disable-next-line
import Home from '../pages/home.vue';
// eslint-disable-next-line
import Config from '../pages/config.vue';
Vue.use(Router);
export default new Router({
mode: 'hash',
routes: [
{ path: '/', component: Home },
{ path: '/config', component: Config },
],
});
When I run npm run dev and access the above routes, I have the following output:
Up to here, everything is working fine. The problem is when I use the history mode, I can’t access to localhost:8080/config:
And the console doesn’t show any error:
Another thing I tried was switching the mode to history using the simple-webpack template. The worst part is that it worked! So, the problem is in the webpack-template, but I don't know how to make this work.
I'll appreciate any help.