Skip to content
Advertisement

Syntax error: SyntaxError: Cannot use import statement outside a module line: 1 file: Code.gs

I wanted to create a script, which would send data from the google form to the discord webhook in google apps script. But I receive the error in the first line:

import { client as _client } from 'discord.js';
const client = new _client();

Here is the error:

Syntax error: SyntaxError: Cannot use import statement outside a module line: 1 file: Code.gs

Advertisement

Answer

discord.js depends on Node.js. It cannot run on Google Apps Script.

If you want to contact a discord webhook, then do so directly using the UrlFetchApp API as per the External APIs guide.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement