Skip to content

Error ReferenceError: module is not defined (anonymous) @ echo:gs.1 #717

Open
@freddieventura

Description

@freddieventura

Hi there,

Thanks for your resource first off.
I'm trying to set it up following the instructions but I am unable to do so as I end up having a compilation error in GAS
I had to modify some things in what you were doing in order to sort out my own way, such as installing .

Mainly I installed it the following way (note I'm using clasp)

mkdir messing06
cd messing06/
clasp create --title "messing06"
npm init -y
npm install gas-webpack-plugin
npm install webpack-cli
npm install webpack
vim package.json

On there I

    "build": "webpack --mode production"

The rest of the files are just as in the example
vim echo.js

module.exports = function(message) {
  return message;
}

vim main.js

var echo = require('./echo');
/**
 * Return write arguments.
 */
global.echo = echo;

vim webpack.config.json

const GasPlugin = require("gas-webpack-plugin");
module.exports = {
  context: __dirname,
  entry: "./main.js",
  output: {
    path: __dirname ,
    filename: 'Code.gs'
  },
  plugins: [
    new GasPlugin()
  ]
}

I proceed to build

npm run build

Which generates the Code.gs that I end up clasp push to google

Unfortunatelly I get the aforementioned error when Running it from the Website

Error ReferenceError: module is not defined (anonymous) @ echo:gs.1

Any ideas?

Here you have a sum up of the process. Thank you!!

https://asciinema.org/a/rC1So5vdpTGAHJVQx34k0OSq7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions