Postingan lainnya
Error babel-cli
saya baru belajar nodejs dan menggunakan babel-cli, dan menggalami error saat penulisan sintak es2015
sourcode
import express from "express";
const app = express();
app.listen(5000,(err)=>{
if(err) console.log(err);
console.log("yeeeee");
})
simple server
errornya
(function (exports, require, module, __filename, __dirname) { import express from "express";
^^^^^^^
SyntaxError: Unexpected identifier
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)
mohon bimbinganya
0
1 Jawaban:
Mungkin link ini bisa membantu <a href=' https://timonweb.com/posts/how-to-enable-es6-imports-in-nodejs/ '>How To Enable ES6 Imports in Node.JS</a>
0
Tanggapan
yg ES5 kak
Kirain ES6, karena es2015 = ES6.
kalau es5, jadi seperti ini: const express = require("express")