基于node的项目,unexcepted token *?

clipboard.png

在main.js中引用npm install three 安装的three.js

import * as THREE from 'three';
const scene = new THREE.Scene();
console.log('111111',scene);

然后通过 node main.js 启动提示错误

clipboard.png

这个是什么原因导致的应该怎么改?

阅读 11.3k
3 个回答

本身 nodejs 连 esModule 都不支持 跟何况你用 * ;

nodejs 本身是有自己的模块系统方式的

require()

module.exports

如果想要在nodejs中使用 esModule 建议参考 这个文档 nodejs es module

threejs不是跑在浏览器的吗

应该是不支持这种方式导入
你一个个导入试试

1 篇内容引用
推荐问题