import path from 'path';
const obj = path.parse('img/works.png');
obj是undefined,官方说应该类似:
{
root : "/",
dir : "/home/user/dir",
base : "file.txt",
ext : ".txt",
name : "file"
}
https://nodejs.org/api/path.html#path_path_parse_pathstring
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
你使用的是ES6的module引入方式,最新的nodeJS版本5.0.0是不支持的,目前我知道nodeJS新版本增加了对ES6的部分规范的支持,不包括它的module,你还是使用require引入吧!,如果一定要使用ES6的module引入的话,请添加这个Polyfill: https://github.com/ModuleLoader/es6-module-loader
正确的写法
应该是
或者