Cannot use import statement outside a module
Closed this issue · 4 comments
I've been trying to use these constructs in my CDK infra, but repeatedly run into the following trace on all versions of 13.x.x
:
/node_modules/aws-delivlib/lib/auto-build.ts:1
import {
^^^^^^
SyntaxError: Cannot use import statement outside a module
at compileFunction (<anonymous>)
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Module._compile (node:internal/modules/cjs/loader:1065:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Object.require.extensions.<computed> [as .ts] (/home/philcali/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1361:43)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
Subprocess exited with error 1
Environment
- node: 16.13.1
- npm: 8.3.2
- uname:
Linux localhost 5.4.157-17191-g6575d22de694 #1 SMP PREEMPT Thu Jan 20 19:50:13 PST 2022 x86_64 x86_64 x86_64 GNU/Linux
Steps to reproduce
- In a clean workspace using the latest
aws-cdk
tool, init a new app:
cdk init app --language=typescript
- Update the package.json to match transitive deps for this package:
"devDependencies": {
"@types/jest": "^27.4.0",
"@types/node": "^12",
"aws-cdk": "^1.143.0",
"jest": "^27.4.7",
"ts-jest": "^27.1.3",
"typescript": "~4.5.5"
},
"dependencies": {
"aws-delivlib": "^13",
"constructs": "^3.3.208",
"monocdk": "^1.143.0",
"source-map-support": "^0.5.16"
}
- Update
bin/*.ts
andlib/*-stack.ts
to usemonocdk
instead ofaws-cdk-lib
. - Add
delivlib
pipeline to the stack:
new delivlib.Pipeline(this, 'ConsutructsPipeline', {
repo: new delivlib.GitHubRepo({
repository: 'username/yourRepo',
tokenSecretArn: 'GITHUB_TOKEN_NAME'
})
});
- Run
cdk ls
- Experience failure.
Workaround
I had to downgrade to 12.7.2
to before cdk deploy
would work: https://www.npmjs.com/package/aws-delivlib/v/12.7.2
I'm seeing this issue as well. Have you managed to find a solution?
Only thing that worked for me was to revert to version 12.7.2
of aws-delivlib
(this is not ideal long term, however).
This issue is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon. If you wish to exclude this issue from being marked as stale, add the "backlog" label.
Closing this issue as it hasn't seen activity for a while. Please add a comment @mentioning a maintainer to reopen. If you wish to exclude this issue from being marked as stale, add the "backlog" label.