Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected token (*)

This line of code is giving me problems,

import * as posenet from '@tensorflow-models/posenet'

And I get this error 'Uncaught SyntaxError: Unexpected token *',

I am using the latest version of chrome and have npm package '@tensorflow-models/posenet' installed.I am using npm package 'http-server' to localhost my page.

like image 972
Iexist Avatar asked Sep 06 '25 13:09

Iexist


1 Answers

You can't import npm packages directly like that as the browser has no idea where a package on your server is stored.

In the browser you import javascript files directly using it's path, ie from 'some/file.js'. Also your code has to be in a module type script element for it to use the import/export syntax. For instance

<script type="module">
  import * as someName from 'some/file.js';
</script>
like image 177
Patrick Evans Avatar answered Sep 09 '25 04:09

Patrick Evans