Why does nodejs path.parse return undefined

  node.js, question
import path from 'path';
 const obj = path.parse('img/works.png');

Obj is undefined, and officials say it should be similar:

bracket
 root : "/",
 dir : "/home/user/dir",
 base : "file.txt",
 ext : ".txt",
 name : "file"
 bracket

https://nodejs.org/api/path.html#path_path_parse_pathstring

You are using the module introduction method of ES6, and the latest nodeJS version 5.0.0 is not supported. At present, I know that the new nodeJS version has increased support for some specifications of ES6, not including its module. You should use require to introduce it. , if must use ES6 module to introduce, please add this Polyfill:https://github.com/ModuleLoader/es6-module-loader

Correct writing

var path = require('path');
 const obj = path.parse('img/works.png');