Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

(node:5547) UnhandledPromiseRejectionWarning: TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".json"

import { readFile } from 'fs/promises';

const json = JSON.parse(await readFile(new URL('../../package.json', import.meta.url)));
Comment

(node:5547) UnhandledPromiseRejectionWarning: TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".json"

node --experimental-json-modules about.js
Comment

(node:5547) UnhandledPromiseRejectionWarning: TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".json"

import { createRequire } from "module"; // Bring in the ability to create the 'require' method
const require = createRequire(import.meta.url); // construct the require method
const my_json_file = require("path/to/json/your-json-file.json") // use the require method
Comment

PREVIOUS NEXT
Code Example
Javascript :: alphabet javascript 
Javascript :: installe datatable to reactjs project 
Javascript :: js getelementbyid 
Javascript :: ionic cordova icon notification 
Javascript :: sort array of objects by string property value 
Javascript :: simplebar react 
Javascript :: jquery find previous element with class 
Javascript :: how to create a package.json file in npm 
Javascript :: generate random id javascript 
Javascript :: how to change attribute link in javascript 
Javascript :: ACCESS IFRAME INNER HTML IN CHROME CONSOLE 
Javascript :: mongodb update many 
Javascript :: select checked checkboxes javascript 
Javascript :: open modal in jqwuery 
Javascript :: js remove item array 
Javascript :: NodeJS get rootpath of our project 
Javascript :: react native change app name 
Javascript :: regex for non empty string 
Javascript :: react native image blur 
Javascript :: disable submit button if input is empty 
Javascript :: react addeventlistener useeffect 
Javascript :: select2 clear fields 
Javascript :: [Error - 10:52:45 PM] Failed to load jshint library 
Javascript :: typeorm where in 
Javascript :: link on click jquery 
Javascript :: conditional field validation with Yup 
Javascript :: pwa angular npm 
Javascript :: if datatable is null js 
Javascript :: outer width jquery 
Javascript :: how to integrate redux dev tool to react application 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =