question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

‼️ NOTICE: "Cannot use import statement outside a module" in CodeBuild in 1.95.0

See original GitHub issue

Please add your +1 👍 to let us know you have encountered this issue.


Status: IN-PROGRESS

Overview:

In version 1.95.0 of CDK, the CodeBuild module fails to load with an exception:

Cannot use import statement outside a module

Complete Error Message:

/Users/asmajlovic/code/marsconnected-cdk/node_modules/@aws-cdk/aws-codebuild/node_modules/@aws-cdk/yaml-cfn/lib/yaml.ts:1
import * as yaml from 'yaml';
^^^^^^
SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:355:18)
    at wrapSafe (node:internal/modules/cjs/loader:1022:15)
    at Module._compile (node:internal/modules/cjs/loader:1056:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/asmajlovic/code/marsconnected-cdk/node_modules/ts-node/src/index.ts:1045:43)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:996:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/Users/asmajlovic/code/marsconnected-cdk/node_modules/@aws-cdk/aws-codebuild/node_modules/@aws-cdk/yaml-cfn/lib/index.ts:1:1)

Workaround:

Roll back to version 1.94.1.

Solution:

Related Issues:


Original issue

Synth’ing a CDK pipeline fails after upgrading to 1.95.0

Reproduction Steps

Upgrade from 1.94.1 or earlier to 1.95.0

What did you expect to happen?

expected the stack to successfully synth

What actually happened?

C:\Users\graeme\cloudcycle\DataStorage\node_modules@aws-cdk\aws-codebuild\node_modules@aws-cdk\yaml-cfn\lib\yaml.ts:1 import * as yaml from ‘yaml’; ^^^^^^

SyntaxError: Cannot use import statement outside a module at wrapSafe (internal/modules/cjs/loader.js:979:16) at Module._compile (internal/modules/cjs/loader.js:1027:27) at Module._extensions…js (internal/modules/cjs/loader.js:1092:10) at Object.require.extensions.<computed> [as .ts] (C:\Users\graeme\cloudcycle\DataStorage\node_modules\ts-node\src\index.ts:1045:43) at Module.load (internal/modules/cjs/loader.js:928:32) at Function.Module._load (internal/modules/cjs/loader.js:769:14) at Module.require (internal/modules/cjs/loader.js:952:19) at require (internal/modules/cjs/helpers.js:88:18) at Object.<anonymous> (C:\Users\graeme\cloudcycle\DataStorage\node_modules@aws-cdk\aws-codebuild\node_modules@aws-cdk\yaml-cfn\lib\index.ts:1:1) at Module._compile (internal/modules/cjs/loader.js:1063:30)

Environment

  • **CDK CLI Version :1.95.0
  • **Framework Version:1.95.0
  • **Node.js Version: v14.15.5
  • **OS :Windows 10
  • **Language (Version): typescript": "4.2.3

Other

Simple CDKPipline using a GitHubSourceAction with SimpleSynthAction.standardNpmSynth

No usage of the new BuildSpec.fromObjectToYaml method added in #13445


This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:13
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
skinny85commented, Mar 26, 2021

The fix in 1.95.1 has been released, and customers are seeing recovery.

Resolving this issue, please comment if you run into it again!

0reactions
github-actions[bot]commented, Mar 26, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SyntaxError: Cannot use import statement outside a module
But I don't see how the suggestion to use import() to access es6 module in CommonJS is useful. It's async and so can't...
Read more >
Cannot use import statement outside a module [React ...
When building a web application, you may encounter the SyntaxError: Cannot use import statement outside a module error.
Read more >
Cannot use import statement outside a module · Issue # ...
When you use ECMAScript Modules in Node (v13.6.0 for me) combined with Jest, the following error occurs: SyntaxError: Cannot use import ...
Read more >
JS Fix For "SyntaxError: Cannot Use Import Statement ...
"SyntaxError: Cannot use import statement outside a module" is a common Node.js error when working with import to include modules or ...
Read more >
How to Fix "SyntaxError: Cannot use import statement ...
The error "SyntaxError: Cannot use import statement outside a module" is caused by the fact that the file you're trying to import is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found