1

I'm writing my first Azure Function in Node. This is in VS Code on my local machine. I'm requiring some js code I'd written for a Chrome extension but it's not compiling. For instance, this spread operator

if (otherProps) this.props[indx] = {
    ...this.props[indx],
    ...otherProps
};

Generates the following error:

...this.props[indx], ^^^ SyntaxError: Unexpected token ... at createScript (vm.js:56:10) at Object.runInThisContext (vm.js:97:10)

node.green shows full compatability for spread at node 8.6, Azure v1 is 8.11, so I don't think it's that.

Have I missed something simple here? Of note, I'm getting all sorts of errors with most of the node packages I tried to require. Spread operators, replace, nodeType all failed.

strattonn
  • 1,790
  • 2
  • 22
  • 41
  • How are you installing your libraries? Can you check this https://stackoverflow.com/questions/36461247/how-can-i-use-package-management-in-nodejs-azure-functions – Carlos Alves Jorge May 30 '19 at 13:39
  • I am using npm install but I should have mentioned this is a local VS Code version, question has been modified to include this. – strattonn May 30 '19 at 21:54

1 Answers1

1

Azure v1 targets node v6, v2 targets 8 & 10, spread operator is not available in v6.

strattonn
  • 1,790
  • 2
  • 22
  • 41