Q:

Import JSON file in NodeJs using es6

Hi i'm currently learning nodejs and I try to import a json file like this :

'use strict'

import data from 'users.json'

console.log(data)

Each time I get this error "Cannot find package 'users.json'"
But if I read the file with fs it worked so can you explain me how to do please

A:

try :
import data from './users'

which is the es6 method of doing things or if you want an older syntax method you can try 
const data = require('./users')

Okay so the explanation just is this, those fullstops and forward slash are used to indicate relative paths to the file the import is being called from, which means somethings you'd see something like for example ../file/help. The ./ means go up one directory ../ means go up two directories and so on. The name after the slash just tells your program the folder to go in to look for the file to import from so ./folder means go up one directory and enter into the folder directory and so on.
Almost forgot to mention, you should not import from a json file or a text file or any other file that does not have a .js extention(of which you do not actually have to specify) unless absolutely neccessary. To deal with files in node you have to use the fs library.
const fs =require('fs')

....

fs.readFile('./users.json','utf-8',(err,jsonString)=>{
        const data = JSON.parse(jsonString);
         //whatever other code you may fanacy
         }

take a look at the fs module for a list of awesome features you can use to play with files

