Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js “怎么做?”;进口;语句将在使用react js的服务器端渲染中工作?_Node.js_Reactjs_Express_Server Side Rendering - Fatal编程技术网

Node.js “怎么做?”;进口;语句将在使用react js的服务器端渲染中工作?

Node.js “怎么做?”;进口;语句将在使用react js的服务器端渲染中工作?,node.js,reactjs,express,server-side-rendering,Node.js,Reactjs,Express,Server Side Rendering,当我们试图导入节点js服务器文件中的文件时,import语句出错。如何在NodeJS服务器文件中使用es6 需要安装哪些依赖项?通常使用babel(@babel/core、@babel/preset env和@babel/node,具体取决于需求)来使用导入 以及类似于以下内容的babel配置: { "presets": [ ["@babel/preset-env", { "targets": { "node": "8" } }]

当我们试图导入节点js服务器文件中的文件时,import语句出错。如何在NodeJS服务器文件中使用es6

需要安装哪些依赖项?

通常使用babel(@babel/core、@babel/preset env和@babel/node,具体取决于需求)来使用导入

以及类似于以下内容的babel配置:

{
  "presets": [
    ["@babel/preset-env", {
      "targets": {
        "node": "8"
      }
    }]
  ]
}
对于node的更高版本,您可以运行
node--experimental modules index.mjs
,您需要使用.mjs扩展名,否则它将无法工作(没有额外的配置也不行)