auto-tag icon indicating copy to clipboard operation
auto-tag copied to clipboard

run time error in latest release; npm test failures

Open robertwilkinson9 opened this issue 1 year ago • 4 comments

consistent run time error:

2024-02-01T08:07:58.272Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.UserCodeSyntaxError","errorMessage":"SyntaxError: Cannot use import statement outside a module","stack":["Runtime.UserCodeSyntaxError: SyntaxError: Cannot use import statement outside a module","    at _loadUserApp (file:///var/runtime/index.mjs:1084:17)","    at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:21)","    at async start (file:///var/runtime/index.mjs:1282:23)","    at async file:///var/runtime/index.mjs:1288:1"]}

npm test errors:

[cloudshell-user@ip-10-134-44-138 auto-tag]$ npm run test

> [email protected] test
> babel-node --config-file ./babelrc-node ./node_modules/.bin/jasmine --random=false

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/cloudshell-user/src/auto-tag/spec/autotag_spec.js from /home/cloudshell-user/src/auto-tag/node_modules/jasmine/lib/loader.js not supported.
Instead change the require of autotag_spec.js in /home/cloudshell-user/src/auto-tag/node_modules/jasmine/lib/loader.js to a dynamic import() which is available in all CommonJS modules.
    at Object.newLoader [as .js] (/home/cloudshell-user/src/auto-tag/node_modules/pirates/lib/index.js:121:7)
    at Loader.requireShim [as require_] (/home/cloudshell-user/src/auto-tag/node_modules/jasmine/lib/loader.js:26:3)
    at /home/cloudshell-user/src/auto-tag/node_modules/jasmine/lib/loader.js:19:12
    at new Promise (<anonymous>)
    at Loader.load (/home/cloudshell-user/src/auto-tag/node_modules/jasmine/lib/loader.js:18:12)
    at Jasmine._loadFiles (/home/cloudshell-user/src/auto-tag/node_modules/jasmine/lib/jasmine.js:210:23)
    at Jasmine.loadSpecs (/home/cloudshell-user/src/auto-tag/node_modules/jasmine/lib/jasmine.js:201:14)
    at Jasmine.execute (/home/cloudshell-user/src/auto-tag/node_modules/jasmine/lib/jasmine.js:584:14) {
  code: 'ERR_REQUIRE_ESM'
}
[cloudshell-user@ip-10-134-44-138 auto-tag]$ 

Unsure if they are related.

robertwilkinson9 avatar Feb 01 '24 08:02 robertwilkinson9

Installed this today with "latest" and getting the same error. Cannot use import statement outside a module

gtoonstra avatar Feb 02 '24 14:02 gtoonstra

Installed this today with "latest" and getting the same error. Cannot use import statement outside a module

In my case I rebuilt using local v18.19.0 runtime and when run using update-master, the tagging started to work.

gtoonstra avatar Feb 02 '24 14:02 gtoonstra

Thank you @gtoonstra - running update-master fixed it for me too :-)

robertwilkinson9 avatar Feb 05 '24 15:02 robertwilkinson9

When I say fixed, I meant that the code correctly tagged a new EC2 instance.

I tested the creation of an S3 bucket, which failed with

"responsePayload":{"errorType":"InvalidTag","errorMessage":"The TagValue you have provided is invalid"

I did not specify any additional tags apart from the --custom-tags I supplied when I deployed the code. (The custom tag appears correctly in the EC2 invocation).

Anecdotally I saw the correct tagging of a network interface when a vpc was attached to it, and log groups which already exist are not handled correctly.

robertwilkinson9 avatar Feb 06 '24 10:02 robertwilkinson9