After running ionic serve facing error: Cannot find type definition file for 'node' - node.js

After running ionic serve facing error: Cannot find type definition file for 'node'. I have reinstall ionic, cordova and node.js but still faceing this error
C:\Users\ali\Documents\TransporterApp>ionic serve
[INFO] Starting app-scripts server: --port 8100 --p 8100 --livereload-port 35729 --r 35729 --address 0.0.0.0 - Ctrl+C to
cancel
[21:24:00] watch started ...
[21:24:00] build dev started ...
[21:24:00] clean started ...
[21:24:00] clean finished in 3 ms
[21:24:00] copy started ...
[21:24:00] transpile started ...
[21:24:07] typescript: ...ts/TransporterApp/node_modules/#angular/tsc-wrapped/src/vinyl_file.d.ts, line: 1
Cannot find type definition file for 'node'.
L1: export interface VinylFile extends Object {
L2: path: string;
[21:24:07] typescript: ...ts/TransporterApp/node_modules/#angular/tsc-wrapped/src/vinyl_file.d.ts, line: 11
Cannot find name 'Buffer'.
[21:24:07] typescript: ...D2D-Transporter/node_modules/#ionic/app-scripts/dist/util/clean-css-factory.d.ts, line: 2
Namespace ''*'' has no exported member 'Options'.
L1: import * as cleanCss from 'clean-css';
L2: export declare function getCleanCssInstance(options: cleanCss.Options): cleanCss;
L3: export interface CleanCssConfig {
[21:24:07] typescript: ...D2D-Transporter/node_modules/#ionic/app-scripts/dist/util/clean-css-factory.d.ts, line: 2
Cannot find name 'cleanCss'.
L1: import * as cleanCss from 'clean-css';
L2: export declare function getCleanCssInstance(options: cleanCss.Options): cleanCss;
L3: export interface CleanCssConfig {
[21:24:07] typescript: ...D2D-Transporter/node_modules/#ionic/app-scripts/dist/util/clean-css-factory.d.ts, line: 6
Namespace ''*'' has no exported member 'Options'.
L5: destFileName: string;
L6: options?: cleanCss.Options;
[21:24:07] typescript: ...2D-Transporter/node_modules/#ionic/app-scripts/dist/util/virtual-file-utils.d.ts, line: 1
Cannot find type definition file for 'node'.
L1: import { Stats } from 'fs';
L2: export declare class VirtualStats implements Stats {
[21:24:07] typescript: ...2D-Transporter/node_modules/#ionic/app-scripts/dist/util/virtual-file-utils.d.ts, line: 3
Cannot find name 'Stats'.
L2: export declare class VirtualStats implements Stats {
L3: protected _path: string;
L4: protected _ctime: Date;
[21:24:07] dev server running: http://localhost:8100/
[INFO] Development server running
Local: http://localhost:8100
[21:24:07] copy finished in 6.75 s
[21:24:07] watch ready in 6.97 s
System info are:
cli packages:
#ionic/cli-plugin-ionic-angular : 1.4.0 (C:\Users\ali\Documents\TransporterApp\node_modules\#ionic\cli-plugin-ionic-angular)
#ionic/cli-utils : 1.6.0 (C:\Users\ali\Documents\TransporterApp\node_modules\ionic\node_modules\#ionic\cli-utils)
ionic (Ionic CLI) : 3.6.0 (C:\Users\ali\Documents\TransporterApp\node_modules\ionic)
global packages:
Cordova CLI : 7.0.1
local packages:
#ionic/app-scripts : 1.3.7
#ionic/cli-plugin-cordova : 1.4.1
Cordova Platforms : none
Ionic Framework : ionic-angular 3.2.1
System:
Android SDK Tools : 25.2.5
Node : v6.11.1
OS : Windows 7
npm : 3.10.10

I encountered to this issue before:
npm install #types/node --save-dev
worked for me.

Related

installing the proper version of react-native

I want to make a project that contains the Viro package, so that package needs the react-native version 0.65.1 so I tried to downgrade react-native from 0.68.2 to the supported version of the package 0.65.1 when testing the project on expo I get this message
Warning: Invalid version react-native#0.65.1 for expo sdkVersion 45.0.0. Use react-native#0.68.2
Android Bundling failed 1677ms
Unable to resolve module buffer from C:\Users\MrObscure\Desktop\react\Partner\node_modules\safe-buffer\index.js: buffer could not be found within the project or in these directories:
node_modules
If you are sure the module exists, try these steps:
1. Clear watchman watches: watchman watch-del-all
2. Delete node_modules and run yarn install
3. Reset Metro's cache: yarn start --reset-cache
4. Remove the cache: rm -rf /tmp/metro-*
1 | /* eslint-disable node/no-deprecated-api */
> 2 | var buffer = require('buffer')
| ^
3 | var Buffer = buffer.Buffer
4 |
5 | // alternative to using Object.keys for old browsers
and the packages that is used in this project are
import React,{ useRef, useState, useEffect } from "react";
import {I18nManager, ImageBackground,Animated, StyleSheet,TouchableOpacity,Image,Text,TextInput, Alert,ActivityIndicator,ToastAndroid, View } from "react-native";
import AnimatedTypeWriter from 'react-native-animated-typewriter'
import AppLoading from "expo-app-loading";
import { useFonts } from 'expo-font';
import { NavigationContainer } from '#react-navigation/native';
import { createNativeStackNavigator } from '#react-navigation/native-stack';
import { faArrowRightArrowLeft } from "#fortawesome/free-solid-svg-icons";
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { Button,Card,Avatar,ListItem,Icon } from '#rneui/themed';
import { color } from "#rneui/base";
What was the command you ran to downgrade? npm install react-native#0.65.1 would install the specific version you are looking for. Check the pagacke.json file, what version does it say you have? Did you run an npm i after?
What is the expo version? You could manually in the package.json and run expo install.

How to export the configuration of `webpack.config.js` using pure ESM?

I'm trying to convert into pure ESM the webpack.config.js
import path from 'path'
import {fileURLToPath} from 'url'
import HtmlWebpackPlugin from 'html-webpack-plugin'
import CopyPlugin from 'copy-webpack-plugin'
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
import webpack from 'webpack'
var main_config = {
}
var renderer_config = {
}
var config = [
main_config,
renderer_config,
]
export config
I get this error:
yarn start
yarn run v1.22.18
$ yarn run build && ELECTRON_DISABLE_SECURITY_WARNINGS=true electron ./dist/main/main.js
$ npx webpack --config ./webpack.config.js
[webpack-cli] Failed to load '/home/raphy/NEW-Raphy-Template
/webpack.config.js' config
[webpack-cli] SyntaxError: Unexpected token 'export'
at ESMLoader.moduleStrategy (node:internal/modules
/esm/translators:117:18)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:337:14)
at async link (node:internal/modules/esm/module_job:70:21)
I tried also with
export renderer_config, main_config
and with
export renderer_config
export main_config
but still get error
Other info:
node: v16.15.0
O.S. : Ubuntu 20.04 Desktop
npm: v 8.5.5
You will need to export config as default with
export default config
You will also need to update your package.json to set
"type": "module"
or change the extension of the config to .mjs so that node understands this is as es module ( See: https://nodejs.org/api/packages.html#type )

setup webpack config in nextJS (next.config.js)

I'm working with NextJS and using react-data-export plugin to generate xls files.
in the description it says :
This library uses file-saver and xlsx and using
json-loader will do the magic for you.
///webpack.config.js
vendor: [
.....
'xlsx',
'file-saver'
],
.....
node: {fs: 'empty'},
externals: [
{'./cptable': 'var cptable'},
{'./jszip': 'jszip'}
]
but I have no idea how to implement it and got error like this :
The static directory has been deprecated in favor of the public directory. https://err.sh/vercel/next.js/static-dir-deprecated
Defining routes from exportPathMap
event - compiled successfully
> Ready on http://localhost:80 or http://localhost
> Ready on https://localhost:443 or https://localhost
event - build page: /menu_accounting/ReportGross
wait - compiling...
error - ./node_modules/react-export-excel/node_modules/xlsx/xlsx.js
Module not found: Can't resolve 'fs' in '/home/ahmadb/repos/lorry-erp/node_modules/react-export-excel/node_modules/xlsx'
Could not find files for /menu_accounting/ReportGross in .next/build-manifest.json
I had the same problem, the solution for me was this:
Install this packages (if you installed, ignored this)
npm install file-saver --save
npm install xlsx
npm install --save-dev json-loader
Add this to your nextjs.config.js
const path = require('path')
module.exports = {
...
//Add this lines
webpack: (config, { isServer }) => {
// Fixes npm packages that depend on `fs` module
if (!isServer) {
config.node = {
fs: 'empty'
}
}
return config
}
}

Rollup: Unresolved Dependencies

I'm having issues using npm packages with rollup (specifically lodash).
I'm getting an unresolved dependencies error. I have installed both rollup-plugin-node-resolve and rollup-plugin-commonjs and configured according to the docs. It's possible I could have missed something obvious.
Error
[~/Projects/rollup] yarn run build
yarn run v1.2.1
$ rollup -c
src/main.js → ./build/app.js...
(!) Unresolved dependencies
https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as-external-dependency
loadash (imported by src/main.js)
(!) Missing global variable name
Use options.globals to specify browser global variable names corresponding to external modules
loadash (guessing 'loadash')
created ./build/app.js in 47ms
✨ Done in 0.93s.
src/main.js
import { map } from 'loadash';
console.log('Test');
rollup.config.js
import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';
export default {
input: 'src/main.js',
output: {
file: './build/app.js',
format: 'iife'
},
plugins: [
resolve({
jsnext: true,
main: true,
browser: true,
}),
commonjs()
]
};
What am I doing wrong?
It's called lodash, not loadash!

Gulp inject: Segmentation Fault

I have manjaro linux and I installed nodejs and npm from official repositories
node version: v6.2.1
npm version: 3.9.5
gulp.task('inject', ['scripts', 'styles'], function () {
var injectStyles = gulp.src([
path.join(conf.paths.tmp, '/serve/app/**/*.css'),
path.join('!' + conf.paths.tmp, '/serve/app/vendor.css')
], { read: false });
var injectScripts = gulp.src([
path.join(conf.paths.src, '/app/**/*.module.js'),
path.join(conf.paths.src, '/app/**/*.js'),
path.join('!' + conf.paths.src, '/app/**/*.spec.js'),
path.join('!' + conf.paths.src, '/app/**/*.mock.js'),
])
.pipe($.angularFilesort()).on('error', conf.errorHandler('AngularFilesort'));
var injectOptions = {
ignorePath: [conf.paths.src, path.join(conf.paths.tmp, '/serve')],
addRootSlash: false
};
return gulp.src(path.join(conf.paths.src, '/*.html'))
.pipe($.inject(injectStyles, injectOptions))
.pipe($.inject(injectScripts, injectOptions))
.pipe(wiredep(_.extend({}, conf.wiredep)))
.pipe(gulp.dest(path.join(conf.paths.tmp, '/serve')));
});
When I run:
$ gulp serve
It display me:
[21:36:37] Using gulpfile /home/jics/Documents/Proyect/gulpfile.js
[21:36:37] Starting 'config'...
[21:36:37] Starting 'styles'...
[21:36:37] Finished 'config' after 236 ms
[21:36:37] Starting 'scripts'...
[21:36:37] gulp-inject 30 files into index.scss.
[21:36:39] Finished 'styles' after 2.36 s
[21:36:40] all files 211.97 kB
[21:36:40] Finished 'scripts' after 2.84 s
[21:36:40] Starting 'inject'...
[21:36:40] gulp-inject 1 files into index.html.
Segmentation fault
My coredumctl display me:
PID: 29909 (gulp)
UID: 1000 (jics)
GID: 1000 (jics)
Signal: 11 (SEGV)
Timestamp: lun 2016-06-13 18:03:49 CLT (3h 37min ago)
Command Line: gulp
Executable: /usr/bin/node
Control Group: /user.slice/user-1000.slice/session-c2.scope
Unit: session-c2.scope
Slice: user-1000.slice
Session: c2
Owner UID: 1000 (jics)
Boot ID: 857cb1e6f9134beb91d172fc85f05f36
Machine ID: 50f47fe8f80b4f92829b61933e8b309e
Hostname: jics-pc
Coredump: /var/lib/systemd/coredump/core.gulp.1000.857cb1e6f9134beb91d172fc85f05f36.29909.1465
Message: Process 29909 (gulp) of user 1000 dumped core.
Stack trace of thread 29909:
#0 0x00002080c7ca188c n/a (n/a)
The only why I can run gulp serve with success is deleting de follow line from de configuration file .pipe($.inject(injectScripts, injectOptions))
Well I did do it with n
$ sudo npm install -g n
$ sudo n stable
install : node-v6.2.1
mkdir : /usr/local/n/versions/node/6.2.1
fetch : https://nodejs.org/dist/v6.2.1/node-v6.2.1-linux-x64.tar.gz
######################################################################## 100,0%
installed : v6.2.1
Finally I do $ gulp serve and run perfectly

Resources