npm run build failed - node.js

I have used microsoft-graph-client and isomorphic-fetch npm package in our project for accessing Microsoft Graph, but while running npm run build command, its throwing errors from node_modules.
node_modules/#microsoft/microsoft-graph-client/lib/src/GraphRequest.d.ts:184:55 - error TS2304: Cannot find name 'HeadersInit'.
184 headers(headers: KeyValuePairObjectStringNumber | HeadersInit): GraphRequest;
~~~~~~~~~~~
node_modules/#microsoft/microsoft-graph-client/lib/src/IContext.d.ts:19:14 - error TS2552: Cannot find name 'RequestInfo'. Did you mean 'RequestInit'?
19 request: RequestInfo;
~~~~~~~~~~~
node_modules/#microsoft/microsoft-graph-client/lib/src/middleware/options/RetryHandlerOptions.d.ts:16:77 - error TS2552: Cannot find name 'RequestInfo'. Did you mean 'RequestInit'?
16 export declare type ShouldRetry = (delay: number, attempt: number, request: RequestInfo, options: FetchOptions | undefined, response: Response) => boolean;
~~~~~~~~~~~
node_modules/#microsoft/microsoft-graph-client/lib/src/tasks/PageIterator.d.ts:34:15 - error TS2304: Cannot find name 'HeadersInit'.
34 headers?: HeadersInit;
~~~~~~~~~~~
Found 4 errors in 4 files.
Errors Files
1 node_modules/#microsoft/microsoft-graph-client/lib/src/GraphRequest.d.ts:184
1 node_modules/#microsoft/microsoft-graph-client/lib/src/IContext.d.ts:19
1 node_modules/#microsoft/microsoft-graph-client/lib/src/middleware/options/RetryHandlerOptions.d.ts:16
1 node_modules/#microsoft/microsoft-graph-client/lib/src/tasks/PageIterator.d.ts:34

Related

Error: Module not found: Error: Can't resolve src/app/app.component.css?ngResource Angular

I'm facing this 3 problems that I still can't understand where your mistakes are.
Error: Module not found: Error: Can't resolve 'C:/Users/DexSh/desktop/C# Angular/Testing/src/app/app.component.css?ngResource' in 'C:\Users\DexSh\desktop\C# Angular\Testing'
Error: Module not found: Error: Can't resolve 'C:\Users\DexSh\desktop\C# Angular\Testing\node_modules\webpack-dev-server\client\index.js?protocol=auto%3A&username=&password=&hostname=0.0.0.0&port=0&pathname=%2Fng-cli-ws&logging=info&overlay=%7B%22errors%22%3Atrue%2C%22warnings%22%3Afalse%7D&reconnect=10&hot=false&live-reload=true' in 'C:\Users\DexSh\desktop\C# Angular\Testing'
Error: The loader "C:/Users/DexSh/desktop/C# Angular/Testing/src/app/app.component.css" didn't return a string.
when using ng build returns this
Warning: ▲ [WARNING] Comments in CSS use "/* ... */" instead of "//" [js-comment-in-css]
C:/Users/DexSh/desktop/C# Angular/Testing/src/app/app.component.css:1:18:
1 │ /******/ (() => { // webpackBootstrap
╵ ~~
Warning: ▲ [WARNING] Unexpected "(" [css-syntax-error]
C:/Users/DexSh/desktop/C# Angular/Testing/src/app/app.component.css:1:9:
1 │ /******/ (() => { // webpackBootstrap
╵ ^
Error: Module not found: Error: Can't resolve 'C:/Users/DexSh/desktop/C# Angular/Testing/src/app/app.component.css?ngResource' in 'C:\Users\DexSh\desktop\C# Angular\Testing'
Error: The loader "C:/Users/DexSh/desktop/C# Angular/Testing/src/app/app.component.css" didn't return a string.
Can anyone tell me what's causing this, it's in every project
Waiting for a normal build and project execution
The problem is that you have a # in your folder name -> (C# Angular).
This f. problem made me to go on rampage too...

getting a failed and type error when runing "npm run build" from a webpack 5 file. I pasted the code below

gregmcnally#Gregs-MacBook-Pro CS55.13-todo-app-week-8-main % npm run build
todo-app-week08#0.1.0 build /Users/gregmcnally/Downloads/CS55.13-todo-app-week-8-main
next build
info - Loaded env from /Users/gregmcnally/Downloads/CS55.13-todo-app-week-8-main/.env.local
info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
Failed to compile.
./pages/ssr-no-token.tsx:62:51
Type error: Argument of type 'IncomingMessage & { cookies: NextApiRequestCookies; }' is not assignable to parameter of type 'null | undefined'.
Type 'IncomingMessage & { cookies: NextApiRequestCookies; }' is not assignable to type 'null'.
60 | // withAuthUserTokenSSR.
61 | const token = await AuthUser.getIdToken()
62 | const endpoint = getAbsoluteURL('/api/example', req)
| ^
63 | const response = await fetch(endpoint, {
64 | method: 'GET',
65 | headers: {
info - Checking validity of types .npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! todo-app-week08#0.1.0 build: next build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the todo-app-week08#0.1.0 build 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! /Users/gregmcnally/.npm/_logs/2021-12-17T02_08_03_370Z-debug.log
gregmcnally#Gregs-MacBook-Pro CS55.13-todo-app-week-8-main %

SyntaxError: Unexpected token export with SPFx solution while running Jest

I am getting this error:
FAIL src\webparts\crud\__test__\CrudWebPart.test.tsx
● Test suite failed to run
C:\Users\admin\Desktop\github\crud-simple-test\node_modules\#microsoft\sp-http\lib\index.js:12
export { default as HttpClient } from './httpClient/HttpClient';
^^^^^^
SyntaxError: Unexpected token export
54 |
55 | async postTodo() {
> 56 | const value = await this.addItem(this.state.todo);
57 | const action = postTodoCreator(value);
58 | store.dispatch(action)
59 | }
at ScriptTransformer._transformAndBuildScript (node_modules/jest/node_modules/jest-runtime/build/script_transformer.js:316:17)
at Object.<anonymous> (src/webparts/crud/components/Todolist/Todolist.tsx:56:68)
at Object.<anonymous> (src/webparts/crud/components/Crud.tsx:17:70)
console.log src\webparts\crud\components\Store\reducers.ts:27
action type ##redux/INITb.1.9.m.y.8 is not found
Handlebars: Access has been denied to resolve the property "statements" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "branches" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "functions" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
Handlebars: Access has been denied to resolve the property "lines" because it is not an "own property" of its parent.
You can add a runtime option to disable the check or this warning:
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | Unknown | Unknown | Unknown | Unknown | |
----------|----------|----------|----------|----------|-------------------|
Jest: Coverage data for global was not found.
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 8.522s
Ran all test suites.
testResultsProcessor support is deprecated. Please use jest reporter. See https://github.com/jest-community/jest-junit#usage:
{
"reporters": [
"jest-junit"
]
}
npm ERR! Test failed. See above for more details.
This is strange, because after doing some research I changed my config:
"transformIgnorePatterns": [
"/node_modules/(?!#microsoft/sp-core-library|sp-dialog|sp-http)"
],
Yet this little fix doesn't seem to cut it even though this seems to be what people did to fix similar issues. Is this a Typescript problem or is it something else? And how do I make sure the Typescript compiler does its job?
In my case, I configured package.json so jest ignores all these:
"transformIgnorePatterns": [ "node_modules/(?!(#microsoft/sp-dialog|#microsoft/office-ui-fabric-react-bundle|#microsoft/sp-diagnostics|#microsoft/sp-core-library|#microsoft/sp-http|#microsoft/sp-page-context|#microsoft/sp-dynamic-data|#pnp/sp|#pnp/common|#pnp/odata|#pnp))" ],

NestJS fastify swagger errors while building app

I'm using fastify adapter
According to the documentation I have installed the swagger adapter for fastify
npm install --save #nestjs/swagger fastify-swagger
And when I import swagger objects
import { DocumentBuilder, SwaggerModule } from '#nestjs/swagger';
Get multiple errors in the building app stage:
node_modules/#nestjs/swagger/dist/decorators/api-body.decorator.d.ts:4:35 - error TS2304: Cannot find name 'Omit'.
4 declare type RequestBodyOptions = Omit<RequestBodyObject, 'content'>;
~~~~
node_modules/#nestjs/swagger/dist/decorators/api-header.decorator.d.ts:3:43 - error TS2304: Cannot find name 'Omit'.
3 export interface ApiHeaderOptions extends Omit<ParameterObject, 'in'> {
~~~~
node_modules/#nestjs/swagger/dist/decorators/api-param.decorator.d.ts:4:33 - error TS2304: Cannot find name 'Omit'.
4 declare type ParameterOptions = Omit<ParameterObject, 'in' | 'schema'>;
~~~~
node_modules/#nestjs/swagger/dist/decorators/api-property.decorator.d.ts:2:45 - error TS2304: Cannot find name 'Omit'.
2 export interface ApiPropertyOptions extends Omit<SchemaObjectMetadata, 'name' | 'enum'> {
~~~~
node_modules/#nestjs/swagger/dist/decorators/api-property.decorator.d.ts:8:80 - error TS2344: Type '"type" | "enum" | "example" | "format" | "deprecated"' does not satisfy the constraint '"name" | "enum"'.
Type '"type"' is not assignable to type '"name" | "enum"'.
8 export declare function ApiResponseProperty(options?: Pick<ApiPropertyOptions, 'type' | 'example' | 'format' | 'enum' | 'deprecated'>): PropertyDecorator;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/#nestjs/swagger/dist/decorators/api-query.decorator.d.ts:4:33 - error TS2304: Cannot find name 'Omit'.
4 declare type ParameterOptions = Omit<ParameterObject, 'in' | 'schema'>;
~~~~
node_modules/#nestjs/swagger/dist/decorators/api-response.decorator.d.ts:3:46 - error TS2304: Cannot find name 'Omit'.
3 export interface ApiResponseMetadata extends Omit<ResponseObject, 'description'> {
~~~~
node_modules/#nestjs/swagger/dist/decorators/api-response.decorator.d.ts:9:48 - error TS2304: Cannot find name 'Omit'.
9 export interface ApiResponseSchemaHost extends Omit<ResponseObject, 'description'> {
~~~~
node_modules/#nestjs/swagger/dist/document-builder.d.ts:20:14 - error TS2304: Cannot find name 'Omit'.
20 build(): Omit<OpenAPIObject, 'components' | 'paths'>;
~~~~
node_modules/#nestjs/swagger/dist/interfaces/schema-object-metadata.interface.d.ts:3:47 - error TS2304: Cannot find name 'Omit'.
~~~~
Has someone ideas what to do?
Okay, I have found the answer.
Open file tsconfig.json and add this line:
{
compilerOptions: {
"skipLibCheck": true
}
}
I'm not sure, that it is the best way because it will skip your node_modules checking while compiling. But to launch, it helps.

How to import Typescript file in Javascript file and interpret its contents before use?

I am writing a Node app with Typescript but my Cucumber test is in Javascript. My question: If I have a Typescript file:
import { Request, Response } from "express";
import checkCredentials from "./components/member/check-member-credentials";
import findMemberByEmail from "./components/member/find-member-by-email";
export default async (req: Request, res: Response) => {
const memberByEmail = await findMemberByEmail(req.body.password);
if (memberByEmail.error) {
return res.status(401).json({ message: "not found" });
}
const isMatch = await checkCredentials(
memberByEmail.member.password,
req.body.password,
);
if (isMatch) {
return res.status(200).json({ message: "logged in" });
}
return res.status(401).json({ message: "not auth" });
};
And I am trying to import it in the context file of Cucumber test:
require('../../../../src/controllers/login.ts');
I get the typical js error:
import { Request, Response } from "express";
^
SyntaxError: Unexpected token {
I tried to use a library typescript-require and require it before my import (as in its docs):
require('typescript-require');
const login = require("../../../../src/controllers/login.ts");
But I'm still getting error:
> NODE_ENV=development ./node_modules/.bin/cucumber-js test
src/controllers/components/member/check-member-credentials.ts(1,25): error TS2307: Cannot find module 'bcryptjs'.
src/controllers/components/member/check-member-credentials.ts(4,3): error TS2304: Cannot find name 'Promise'.
src/controllers/components/member/find-member-by-email.ts(1,16): error TS2307: Cannot find module '../../../db/models/index.js'.
src/controllers/components/member/find-member-by-email.ts(4,2): error TS2304: Cannot find name 'Promise'.
src/controllers/login-test.ts(1,35): error TS2307: Cannot find module 'express'.
src/controllers/login-test.ts(5,16): error TS1057: An async function or method must have a valid awaitable return type.
src/controllers/login-test.ts(11,25): error TS2346: Supplied parameters do not match any signature of call target.
src/controllers/login-test.ts(13,22): error TS1009: Trailing comma not allowed.
Fatal Error. Unable to compile TypeScript file. Exiting.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-basic-fit-v2#1.0.0 e2etest: `NODE_ENV=development ./node_modules/.bin/cucumber-js test`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-basic-fit-v2#1.0.0 e2etest 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! /Users/ali.atrash/.npm/_logs/2019-07-08T14_53_57_742Z-debug.log
Any other solution?

Resources