Unexpected token *

简介:

Env:node v10.5.0


Error:

4ae3e6379c227b946c366ba9875f6fd0f92d5f5f

Code:


import * as tf from '@tensorflow/tfjs';

Solution:


const tf = require('@tensorflow/tfjs');

Reason:

该版本node只支持部分es6的语法,对于import这种就不支持,需要改为es5的语法


Other:

这也解决了刚入行时遇到的一个问题:当时我问同事为什么有的地方使用require("")而有的地方引用不了?原来是语法的原因。问这个问题的根本原因还是对es5和es6的语法不了解

相关文章
|
4月前
|
JavaScript
request to https://registry.npm.taobao.org/cnpm failed, reason: certificate has expired
request to https://registry.npm.taobao.org/cnpm failed, reason: certificate has expired
112 2
|
4月前
|
JSON JavaScript 前端开发
Uncaught SyntaxError: Invalid or unexpected token
Uncaught SyntaxError: Invalid or unexpected token
50 0
|
5月前
|
内存技术
|
存储 安全 前端开发
message“: “CSRF token mismatch
message“: “CSRF token mismatch
487 0
|
JavaScript
fast admin报错:Unexpected token ‘<‘, “ (已解决)
fast admin报错:Unexpected token ‘<‘, “ (已解决)
239 0
eslint: error Parsing error: Unexpected token <
eslint: error Parsing error: Unexpected token <
343 0
错误一例:expected expression before } token
错误一例:expected expression before } token
224 0
|
JSON 数据格式
解决报错信息之:SyntaxError: Unexpected token R in JSON at position 0
解决报错信息之:SyntaxError: Unexpected token R in JSON at position 0
391 0
|
JavaScript
Uncaught SyntaxError: Unexpected token <
Uncaught SyntaxError: Unexpected token <
637 0
Uncaught SyntaxError: Unexpected token <
【C】解决error: expected ‘;’ before ‘)’ token
【C】解决error: expected ‘;’ before ‘)’ token