如果有来自xxx的`import xxx`,我无法在单个`.js`文件中运行

时间:2018-03-22 08:55:54

标签: javascript webstorm

如果有class Base(object): @declared_attr def __tablename__(cls): """Generate the tablename programatically from the class name.""" return cls.__name__.lower() + "s" id = Column(Integer, primary_key=True) @hybrid_property def description(self): """Return a description of the entry.""" return str(self) BASE = declarative_base(cls=Base) class Environment(BASE): """Schema for environments table.""" project = Column(String) version = Column(String) flavor = Column(String) environment = Column(String) some_attribute = Column(String) tests = relationship("Test", back_populates="environment", cascade="all, delete, delete-orphan") def __str__(self): """Return a string representation.""" return (f"{self.project}-{self.version}-" f"{self.flavor}-{self.environment}") @BASE.description.expression def description(cls): return func.concat(cls.project, "-", cls.version, "-", cls.flavor, "-", cls.environment) class Test(BASE): """Schema for tests table.""" environment_id = Column(Integer, ForeignKey("environments.id")) environment = relationship("Environment", back_populates="tests") name = Column(String) credits = Column(Integer) runs = relationship("Run", back_populates="test", cascade="all, delete, delete-orphan") def __str__(self): """Return a string representation of test identifier.""" return f"{self.environment}-{self.name}" @BASE.description.expression def description(cls): return func.concat(cls.environment.description(), "-", cls.name) ,我无法在单.js个文件中运行。

enter image description here

我使用单个文件调试导入的import xxx from xxx,我该如何在WebStorm中执行此操作?

修改-1

配置选择如下:

enter image description here

告诉我该怎么做?

3 个答案:

答案 0 :(得分:1)

您使用的是nodejs的旧版本,v6.6不支持import关键字。请使用版本8或更高版本的import关键字,无需使用像babel这样的任何转发器。

答案 1 :(得分:1)

您尝试使用的功能是ES Modules规范的一部分。

但是,Node.js v9.9.0版本Node.js v10.0.0版本const ts_config = require('./tsconfig.json); 不稳定,不应在生产中使用。 此功能正在开发中,预计将与public function handle($request, Closure $next, $guard = null) { if (Auth::guard($guard)->check()) { if(Auth::user()->hasRole('administrator')) { return redirect('/'); } else { return redirect('client/dashboard'); } } return $next($request); } 一起稳定发布。

现在,你可以这样做:

export default
{
  // json here...
}

答案 2 :(得分:0)

您是否正在导出tsConfig?

{{1}}