nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
107.74k stars 29.68k forks source link

Showing syntaxError while run “node server” #19644

Closed aliridha1510 closed 6 years ago

aliridha1510 commented 6 years ago

package.json

{
    "name": "nodeprojects",
    "version": "1.0.0",
    "description": "Node.js First RestFull Api",
    "main": "index.js",
    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
    },
    "keywords": [
        "node",
        "restful"
    ],
    "author": "ali ri",
    "license": "ISC",
    "dependencies": {
        "express": "^4.16.3"
    },
    "devDependencies": {
        "babel-node-modules": "0.0.1"
    }
}

Console C:\Users\username\WebstormWorksapce\NodeProjects\student.js:1 (function (exports, require, module, filename, dirname) { import { Module } from "module"; ^^^^^^ SyntaxError: Unexpected token import at createScript (vm.js:53:10) at Object.runInThisContext (vm.js:95:10) at Module._compile (module.js:543:28) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) at Module.runMain (module.js:605:10) at run (bootstrap_node.js:423:7) at startup (bootstrap_node.js:147:9)

Process finished with exit code 1

cjihrig commented 6 years ago

Node 7 is not supported anymore. You'll also want to use the --experimental-modules CLI flag. See https://nodejs.org/api/esm.html