尝试测试简单的nodejs脚本时遇到一些错误有人可以帮忙吗
$ node --version
v11.13.0
我正在尝试mathjs
nodejs 中的模块
mkdir mathjs_testing
cd mathjs_testing
npm init
npm install mathjs
测试.js ()https://mathjs.org/docs/getting_started.html#es-modules
import { sqrt } from 'mathjs'
console.log(sqrt(-4).toString()) // 2i
然后我跑
node test.js
我收到这个错误
$ node test.js
/home/simha/maths_testing/test.js:1
import { sqrt } from 'mathjs'
^
SyntaxError: Unexpected token {
at Module._compile (internal/modules/cjs/loader.js:749:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:816:10)
at Module.load (internal/modules/cjs/loader.js:672:32)
at tryModuleLoad (internal/modules/cjs/loader.js:612:12)
at Function.Module._load (internal/modules/cjs/loader.js:604:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:868:12)
at internal/main/run_main_module.js:21:11