当前位置:网站首页>Module import method of node

Module import method of node

2022-06-21 18:28:00 CupidoZ

Module import mode
If you follow es6 Standard writing
node Use export Whether keyword screen can export files
node Use import Whether the keyword screen can import files

const ModuleA = {
    
    getName(){
    
        return 'moduleA ran...'
    }
}


export default ModuleA
import ModuleA from "./module/moduleA.js";

console.log(ModuleA.getName())
{
    
  "name": "moduledemo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "cupido",
  "license": "ISC"
}

原网站

版权声明
本文为[CupidoZ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206211651294296.html