filecoin-client-tutorial icon indicating copy to clipboard operation
filecoin-client-tutorial copied to clipboard

SyntaxError: Unexpected token import

Open sean-lin-tw opened this issue 5 years ago • 4 comments

Hi, I am running Node v8.10.0 on Ubuntu18.04.

When I ran the project with node server.js, it showed a syntax error at the import statement. image How do you get around this?

Thanks!

sean-lin-tw avatar Jul 07 '20 01:07 sean-lin-tw

@jacky6016 if you could try upgrading your version of node that might help.

jimmylee avatar Jul 07 '20 01:07 jimmylee

I upgraded Node to 14.5.0 and change server.js to server.mjs. It can run now.

sean-lin-tw avatar Jul 07 '20 03:07 sean-lin-tw

Doesn't work for me either.

Node - 14.7.0 (LTS) Npm - 6.14.7

Works if you change to

const express = require('express');
const fs = require("fs");
const { ffs, createPow } = require("@textile/powergate-client")

Also, you need to change the placing of some of the variable instantiations.

jeevanpillay0000 avatar Jul 31 '20 05:07 jeevanpillay0000

@lpfloyd I don't think this example has been kept up to date, if you could send a PR that would be great

jimmylee avatar Jul 31 '20 06:07 jimmylee