hapi.js Version 18.x Typings - node.js

I recently upgraded my project to use the #hapi/hapi node modules vs. the old hapi module. I'm using version 18.3.1 ("#hapi/hapi": "^18.3.1").
My Typescript definitions no longer work as the Import reads: import * as Hapi from 'hapi';
When running the node process I get the module not found error. Is there a way to point the #types/hapi typings to the new #hapi/hapi module?

Uninstall the #types/hapi dependency. This didn't work for me moving to 18.3.1. Instead install #types/hapi__hapi. I searched for a while and ran across that package, which seems to do the trick.
npm un #types/hapi -D
npm i #types/hapi__hapi -D
Then instead of importing from 'hapi', import from '#hapi/hapi'.
import * as Hapi from '#hapi/hapi';

Related

I am Unable to downgrade the node-fetch version to 2.x.x from 3.x.x

So basically i want to run a gatsby project in my local system . Every time i run npm run dev-ssl.
I get an error stating
Must use import to load ES Module:
......
require() of ES modules is not supported
It seems i need to downgrade the node-fetch version which is 3.2.2 in my case.
Steps to downgrade that i did
npm uninstall node-fetch;
npm install node-fetch#2.6.1
npm view node-fetch version
It still shows version 3.x.x . I also tried with -g to delete globally but getting the same result.

Using nodejs modules in next.js

I facing a problem with nodejs module not working in my nextjs app. Any help would be appreciated
I'm importing it like this
import {saveAs} from "file-saver";
Module not found
It seems as though you don't have the module installed, to verify it's installed, run the following:
With NPM:
npm install file-saver
With Yarn:
yarn add file-saver

react-router 3.10.10 IndexRoute

I'm trying to figure out how to build apps with react and feathers. I found Ben Awad's YouTube tutorial series (https://www.youtube.com/watch?v=etq_vv_RVcU&index=2&list=PLN3n1USn4xlnulnnBGD2RMid_p7xVj9xU) and was following along with the code. However I somehow got an issue he didn't cover. When I go to run the code produced at the end of this video I get the following error:
./src/index.js
36:23-33 'react-router' does not contain an export named 'IndexRoute'.
Most of the stuff I've found seems to suggest that IndexRoute was phased out in v4, however running npm -v react-route returns 3.10.10 so I don't think it should be affected (could be wrong). Does anyone have any thoughts about what might be causing this issue? Thank you.
I think IndexRoute was removed since version 2 from react-route so you must use version 2 of react-route, in order to do so you can install it using npm:
npm install --save react-router#2
IndexRoute was removed in version 4 meaning that version 3.x still has it. Install with npm:
npm install --save react-router#3.x
or
yarn add react-router#3.x

TypeScript definition for builtin 'net' NodeJS types?

I am trying to write a TCP client application, and for that the builtin 'net' package seems to do the job. However, I am not able to find the TypeScript definitions for the package.
https://nodejs.org/api/net.html
Since it is built into NodeJs, I am almost sure it exists, but it cannot find any information about it anywhere.
Thanks!
They are available in the official typings for node. Install it with npm install #types/node --save-dev and you can import it in your TypeScript code using: import * as net from "net";

how to use #types/node in node application

I am working in VSCode on Ubuntu 16.04. I've created node project using below commads:
npm init
tsc --init
I've created a new file called index.ts. I'm trying to use fs and readling to read file contents. but when I am writing below lines of code at the top of index.d.ts:
import fs = require('fs');
import readline = require('readline');
I'm getting below error:
can not find module 'fs' and can not find module 'readline'
even process is not found.
I've installed typings of node from here using below command:
sudo npm install #types/node -global --save
Can anyone please help me how to resolve this error?
Since TypeScript 2.x, all typings are installed using npm like this: npm install #types/node.
For TypeScript 1.8, it might be better to typings to install the node types. For detail see the quickstart at: https://basarat.gitbooks.io/typescript/content/docs/quick/nodejs.html.
For what i know you have two options here:
(Recommended) Install devDepencencie npm install #types/node --save-dev, which will add the type module for http.
Create a index.d.ts file declaring a definition for http module, like:
declare module 'http. This method will not enable auto-complete for http methods

Resources