Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.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 node app和babel出现问题,出现导入问题:在CLI中运行节点脚本时出现意外{错误_Node.js_Babeljs - Fatal编程技术网

Node.js node app和babel出现问题,出现导入问题:在CLI中运行节点脚本时出现意外{错误

Node.js node app和babel出现问题,出现导入问题:在CLI中运行节点脚本时出现意外{错误,node.js,babeljs,Node.js,Babeljs,很抱歉,问题的标题结构不好,但我不确定该如何设计问题的框架 我正在编写一个全局安装的节点应用程序,它是一个bash可执行文件。我的问题与node和babel有关。因此我将其配置为使用npm run dev。但是,当我从终端运行它时,“hydra”通过“bin”执行它,出现以下错误:SyntaxError:由于{import>而导致意外标记{{template}来自“/template-1”; 节点版本:v10.15.3 package.json { "name": &q

很抱歉,问题的标题结构不好,但我不确定该如何设计问题的框架

我正在编写一个全局安装的节点应用程序,它是一个bash可执行文件。我的问题与node和babel有关。因此我将其配置为使用
npm run dev
。但是,当我从终端运行它时,“hydra”通过“bin”执行它,出现以下错误:
SyntaxError:由于
{import>而导致意外标记{
{template}来自“/template-1”;

节点版本:v10.15.3

package.json


{
  "name": "hydra",
  "version": "1.0.0",
  "description": "template repo",
  "main": "index.js",
  "bin": {
    "hydra": "./bin/defaultscript.js"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "babel-node --no-warnings index.js --dev=true"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@babel/cli": "^7.13.14",
    "@babel/core": "^7.13.15",
    "@babel/node": "^7.13.13",
    "@babel/preset-env": "^7.13.15",
  }
}

B.法律改革委员会

{
  "presets":  ["@babel/preset-env"]
}

index.js

'use strict';

module.exports = require('./bin/defaultscript.js');

bin/defaultscript.js

#!/usr/bin/env node --no-warnings

'use strict';


重复问题:在此处找到答案: