N
Novu•2y ago
AndreLuizsgf

Axios error on bump novu to 0.13.0

Hi, im trying to update @Novu/node to 0.13.0 but i get axios error Generic type 'AxiosResponse<T>' requires between 0 and 1 type arguments when running the project and jest SyntaxError: Cannot use import statement outside a module when running jest. Im using pnpm to manage dependencies in a monorepo application.
6 Replies
Pawan Jain
Pawan Jain•2y ago
Hi @andreluizsgf are you running novu in local?
AndreLuizsgf
AndreLuizsgfOP•2y ago
oh sorry, the problem is with the package @Novu/node.
Pawan Jain
Pawan Jain•2y ago
Hi @andreluizsgf Sorry I missed this post are you still facing this issue?
AndreLuizsgf
AndreLuizsgfOP•2y ago
hi @Pawan Jain . yes im still on this issue. sharing the logs on jest run:
Test suite failed to run

Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

...

Details:

/Users/lojaintegrada/Projects/li/pagali-monorepo-node/node_modules/.pnpm/[email protected]/node_modules/axios/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import axios from './lib/axios.js';
^^^^^^

SyntaxError: Cannot use import statement outside a module

at Runtime.createScriptFromCode (../../node_modules/.pnpm/[email protected]/node_modules/jest-runtime/build/index.js:1728:14)
at Object.<anonymous> (../../node_modules/.pnpm/@[email protected]/node_modules/@novu/shared/dist/cjs/services/http-client/api.client.js:16:33)
Test suite failed to run

Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

...

Details:

/Users/lojaintegrada/Projects/li/pagali-monorepo-node/node_modules/.pnpm/[email protected]/node_modules/axios/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import axios from './lib/axios.js';
^^^^^^

SyntaxError: Cannot use import statement outside a module

at Runtime.createScriptFromCode (../../node_modules/.pnpm/[email protected]/node_modules/jest-runtime/build/index.js:1728:14)
at Object.<anonymous> (../../node_modules/.pnpm/@[email protected]/node_modules/@novu/shared/dist/cjs/services/http-client/api.client.js:16:33)
when trying to run the application
../../node_modules/.pnpm/@[email protected]/node_modules/@novu/node/build/main/lib/changes/changes.d.ts:5:20 - error TS2707: Generic type 'AxiosResponse<T>' requires between 0 and 1 type arguments.

5 get(): Promise<import("axios").AxiosResponse<any, any>>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../node_modules/.pnpm/@[email protected]/node_modules/@novu/node/build/main/lib/changes/changes.d.ts:6:25 - error TS2707: Generic type 'AxiosResponse<T>' requires between 0 and 1 type arguments.

6 getCount(): Promise<import("axios").AxiosResponse<any, any>>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../node_modules/.pnpm/@[email protected]/node_modules/@novu/node/build/main/lib/changes/changes.d.ts:7:41 - error TS2707: Generic type 'AxiosResponse<T>' requires between 0 and 1 type arguments.

7 applyOne(changeId: string): Promise<import("axios").AxiosResponse<any, any>>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../node_modules/.pnpm/@[email protected]/node_modules/@novu/node/build/main/lib/changes/changes.d.ts:8:45 - error TS2707: Generic type 'AxiosResponse<T>' requires between 0 and 1 type arguments.

8 applyMany(changeIds: string[]): Promise<import("axios").AxiosResponse<any, any>>;
../../node_modules/.pnpm/@[email protected]/node_modules/@novu/node/build/main/lib/changes/changes.d.ts:5:20 - error TS2707: Generic type 'AxiosResponse<T>' requires between 0 and 1 type arguments.

5 get(): Promise<import("axios").AxiosResponse<any, any>>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../node_modules/.pnpm/@[email protected]/node_modules/@novu/node/build/main/lib/changes/changes.d.ts:6:25 - error TS2707: Generic type 'AxiosResponse<T>' requires between 0 and 1 type arguments.

6 getCount(): Promise<import("axios").AxiosResponse<any, any>>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../node_modules/.pnpm/@[email protected]/node_modules/@novu/node/build/main/lib/changes/changes.d.ts:7:41 - error TS2707: Generic type 'AxiosResponse<T>' requires between 0 and 1 type arguments.

7 applyOne(changeId: string): Promise<import("axios").AxiosResponse<any, any>>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../node_modules/.pnpm/@[email protected]/node_modules/@novu/node/build/main/lib/changes/changes.d.ts:8:45 - error TS2707: Generic type 'AxiosResponse<T>' requires between 0 and 1 type arguments.

8 applyMany(changeIds: string[]): Promise<import("axios").AxiosResponse<any, any>>;
hi @Pawan Jain did you have time to see this issue? 😄
Paweł T.
Paweł T.•2y ago
hi @andreluizsgf! you probably have to set this option in the TS config of your project:
"compilerOptions": {
...
"skipLibCheck": true
},
"exclude": ["node_modules"]
"compilerOptions": {
...
"skipLibCheck": true
},
"exclude": ["node_modules"]
--
--•2y ago
@andreluizsgf some versions of Jest and Axios are not engaging properly because of the module version that Jest tries to run when using Axios inside a Jest test. We have been flagging that in our code and to the different contributors adding a new provider. https://github.com/novuhq/novu/pull/3218 Another solution is to add this config in the Jest config:
module.exports = {
...
moduleNameMapper: {
axios: 'axios/dist/node/axios.cjs',
},
...
};
module.exports = {
...
moduleNameMapper: {
axios: 'axios/dist/node/axios.cjs',
},
...
};
This will help Jest to run the Axios CJS version and not throw that error anymore.
GitHub
fix(app-generic): allow jest to use axios using cjs by p-fernandez ...
What change does this PR introduce? Instructs Jest to use Axios CJS module. Why was this change needed? Allows the Application Generic package tests to be run in the local environment. Some of th...
Want results from more Discord servers?
Add your server