import node module on react - node.js

I installed react-awesome-query-builder from branch antd-3 but after import on react file, there is an error that says:
import {Query, Builder, Utils as QbUtils} from 'react-awesome-query-builder';
Error :
Failed to compile ./src/shared/queryBuilder/QueryBuilder.js
Module not found: Can't resolve 'react-awesome-query-builder' in 'D:\manshoor_ui\src\shared\queryBuilder'
This module is added to package.json and node_modules but there is this error. I installed by this command:
npm install --save ukrbublik/react-awesome-query-builder#antd-3
So what might be wrong here?

According to github docs documentation for that package, it's supposed to be installed like this:
npm i react-awesome-query-builder
And then you import it like this:
import {Query, Builder, Utils} from 'react-awesome-query-builder';

Related

In Angular application, I keep getting this error Cannot find module 'fs'

In my service file, I import these four libraries:
import * as async from "async";
import * as officegen from "officegen";
import * as path from "path";
import * as fs from "fs";
While there's no problem with async,officegen and path. The fs line keeps giving this error:
ERROR in src/app/matieres/matiere.service.ts(11,45): error TS2307:
Cannot find module 'fs'.
In hopeless attempts, I tried these:
npm install fs -g
npm install fs --save
npm install file-system -g
npm install file-system --save
None of which worked
This is really confusing.
Anyone can help?
You might need to use npm install --save-dev #types/node
Might also need to check tsconfig.json for "moduleResolution": "node"
If that doesn't help, these other questions look similar:
Cannot find module 'fs'
Use fs in typescript

hapi.js Version 18.x Typings

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';

Importing nodejs `fs` with typescript when executing with ts-node?

I'm trying to run the following code with ts-node.
import { writeFileSync, readFileSync } from 'fs';
However I get:
src/main/ts/create.ts (1,45): Cannot find module 'fs'. (2307)
What do I need to do in to allow typescript to import the fs module?
You need to run:
$ npm install #types/node --save-dev
If you need additional information you can refer to the NodeJS QuickStart in the TypeScript Deep Dive by Basarat.

I get an error using NodeJs modules

I've created my first NodeJS module using lodash. When I install my module using npm i mymodule --save and run my index.js script using require('lodash') I get an error with a sub module...
Error : Error: Cannot find module 'lodash'
lodash is well installed but not in the root directory, in the modules directory...
In the source tree of your module you need to run:
npm install lodash --save
And then publish a new version of your module to npm.
The package.json of your module needs to have lodash in its dependencies. If it doesn't then it will not get installed together with your module.

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