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
135 2
|
4月前
|
JSON JavaScript 前端开发
Uncaught SyntaxError: Invalid or unexpected token
Uncaught SyntaxError: Invalid or unexpected token
63 0
|
5月前
|
内存技术
|
中间件 PHP
POST 419 ; message: “CSRF token mismatch.“, exception: “Symfony\Component\HttpKernel\Exception\HttpE
POST 419 ; message: “CSRF token mismatch.“, exception: “Symfony\Component\HttpKernel\Exception\HttpE
138 0
|
存储 安全 前端开发
message“: “CSRF token mismatch
message“: “CSRF token mismatch
511 0
eslint: error Parsing error: Unexpected token <
eslint: error Parsing error: Unexpected token <
359 0
|
JavaScript
fast admin报错:Unexpected token ‘<‘, “ (已解决)
fast admin报错:Unexpected token ‘<‘, “ (已解决)
254 0
|
JavaScript
Uncaught SyntaxError: Unexpected token <
Uncaught SyntaxError: Unexpected token <
644 0
Uncaught SyntaxError: Unexpected token <
【C】解决error: expected ‘;’ before ‘)’ token
【C】解决error: expected ‘;’ before ‘)’ token