我接收到SyntaxError:即使我的节点是v6,也会发生意外的令牌导入。 我错过了什么?如何从'can / construct /'创建import Construct;为我工作而不是要求?
import Construct from 'can/construct/'; // Doesnt work
var Construct = require('can-construct'); // Works for me
var Animal = Construct.extend({
sayHi: function(){
console.log("hi")
}
});
var animal = new Animal()
animal.sayHi();
我知道我需要在ES6中使用import语句。但我已经拥有它了。
/usr/local/bin/node --version
v6.10.1
不确定package.json是否重要:
{
"name": "canjstest",
"version": "1.0.0",
"description": "",
"main": "canjs.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "Test",
"dependencies": {
"canjs": "^2.2.0"
}
}
我错过了什么?
答案 0 :(得分:2)