Javascript 节点NPM语法错误:意外的令牌导入

Javascript 节点NPM语法错误:意外的令牌导入,javascript,node.js,npm,Javascript,Node.js,Npm,我遇到了一个Node/NPM非常流行的问题 我的搜索结果似乎没有一个能准确地解决我的问题 我正在使用Restify&NodeJs…但是一个简单的npm运行启动会产生以下错误 import logger from 'src/modules/amLogger.js'; ^^^^^^ SyntaxError: Unexpected token import at createScript (vm.js:74:10) at Object.runInThisContext (vm.j

我遇到了一个Node/NPM非常流行的问题

我的搜索结果似乎没有一个能准确地解决我的问题

我正在使用Restify&NodeJs…但是一个简单的
npm运行启动
会产生以下错误

import logger   from 'src/modules/amLogger.js';
^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:74:10)
    at Object.runInThisContext (vm.js:116:10)
    at Module._compile (module.js:533:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
My Package.json文件:

{
  "name": "example",
  "version": "0.0.1",
  "author": "Me@me.com",
  "engines": {
    "node": ">=8.2.1",
    "npm": ">=5.3.0"
  },
  "license": "MIT",
  "dependencies": {
    "ascii-art": "^1.4.2",
    "babel-cli": "^6.24.1",
    "babel-core": "^6.25.0",
    "babel-generator": "^6.25.0",
    "babel-plugin-lodash": "^3.2.11",
    "babel-plugin-syntax-async-functions": "^6.13.0",
    "babel-plugin-syntax-trailing-function-commas": "^6.20.0",
    "babel-plugin-transform-async-to-module-method": "^6.16.0",
    "babel-plugin-transform-class-properties": "^6.19.0",
    "babel-plugin-transform-es2015-modules-commonjs": "^6.18.0",
    "babel-plugin-transform-export-extensions": "^6.8.0",
    "babel-plugin-transform-flow-strip-types": "^6.21.0",
    "babel-plugin-transform-object-rest-spread": "^6.20.2",
    "babel-plugin-transform-runtime": "^6.15.0",
    "babel-polyfill": "^6.23.0",
    "babel-preset-es2015": "^6.24.0",
    "babel-register": "^6.18.0",
    "canvas": "^1.6.6",
    "chalk": "^2.0.1",
    "compression": "^1.7.0",
    "documentation": "^5.0.1",
    "dotenv": "^4.0.0",
    "lodash": "^4.17.4",
    "pretty-error": "^2.1.1",
    "restify": "^5.0.1",
    "restify-error": "^1.0.0",
    "restify-plugins": "^1.6.0",
    "socket.io": "^2.0.3",
    "util": "^0.10.3",
    "winston": "^2.3.1"
  },
  "devDependencies": {
    "ascii-art": "^1.4.2",
    "babel-cli": "^6.24.1",
    "babel-core": "^6.25.0",
    "babel-generator": "^6.25.0",
    "babel-plugin-lodash": "^3.2.11",
    "babel-plugin-syntax-async-functions": "^6.13.0",
    "babel-plugin-syntax-trailing-function-commas": "^6.20.0",
    "babel-plugin-transform-async-to-module-method": "^6.16.0",
    "babel-plugin-transform-class-properties": "^6.19.0",
    "babel-plugin-transform-es2015-modules-commonjs": "^6.18.0",
    "babel-plugin-transform-export-extensions": "^6.8.0",
    "babel-plugin-transform-flow-strip-types": "^6.21.0",
    "babel-plugin-transform-object-rest-spread": "^6.20.2",
    "babel-plugin-transform-runtime": "^6.15.0",
    "babel-polyfill": "^6.23.0",
    "babel-preset-es2015": "^6.24.0",
    "babel-register": "^6.18.0",
    "canvas": "^1.6.6",
    "chalk": "^2.0.1",
    "compression": "^1.7.0",
    "documentation": "^5.0.1",
    "dotenv": "^4.0.0",
    "es6-promise": "^4.1.1",
    "lodash": "^4.17.4",
    "pretty-error": "^2.1.1",
    "restify": "^5.0.1",
    "restify-error": "^1.0.0",
    "restify-plugins": "^1.6.0",
    "socket.io": "^2.0.3",
    "util": "^0.10.3",
    "winston": "^2.3.1"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "am:version": "/bin/sh scripts/display.sh",
    "am:pretty-error": "node --require pretty-error/start am.js",
    "am:start": "/bin/sh scripts/display.sh && node am.js",
    "start": "node am.js"
  },
  "description": "example",
  "main": "am.js"
}
这是我的am.js文件

'use strict';

require('dotenv').config();
import logger   from 'src/modules/amLogger.js';
import chalk    from 'chalk';
import util     from 'util';

/**
 * Module Dependencies
 */
const restify   = require('restify'),
    winston     = require('winston'),
    errs        = require('restify-errors'),
    art         = require('ascii-art'),
    compression = require('compression');

// create the Restify Server
const server = restify.createServer({
    name: 'example',
    version: 'v0.0.1',
...
错误发生在从'src/modules/amLogger.js'导入记录器的
但是,如果我注释掉这一行,错误只会移动到下一个import语句——我也尝试在没有
“use strict”的情况下运行它


我缺少什么?

节点还不支持es6导入这里有一篇文章解释了这一点

节点尚不支持es6导入这里有一篇文章对此进行了解释