AWS CDK Code Pipeline Development - Typescript Error TS2307 - aws-cdk

Problem:
Whilst developing my Code Pipeline, I am experiencing a new error I did not receive with cdk deploy --all in the CLI. All stacks deploy successfully.
Code Build Error Message:
src/lambda-handlers/queue-consumers/intoMagentoQueueConsumer/index.ts(3,75): error TS2307: Cannot find module '#aws-sdk/client-sfn' or its corresponding type declarations.
Lambda Function Import Statements:
import { SFNClient, SendTaskSuccessCommand, SendTaskFailureCommand } from "#aws-sdk/client-sfn";
Lambda Function Package.json:
{
"name": "intomagentoqueueconsumer",
"module": "commonjs",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#aws-sdk/client-sfn": "^3.226.0",
"axios": "^1.2.1",
"axios-retry": "^3.3.1"
}
}
Lambda Function CDK Definition:
this.intoMagentoQueueConsumer = new NodejsFunction(this, `intoMagentoQueueConsumer`, {
runtime: Runtime.NODEJS_16_X,
handler: "handler",
depsLockFilePath: join(__dirname, "../../src/lambda-handlers/queue-consumers/intoMagentoQueueConsumer/package-lock.json"),
entry: join(__dirname, "../../src/lambda-handlers/queue-consumers/intoMagentoQueueConsumer/index.ts"),
bundling: { minify: false, nodeModules: ["#aws-sdk/client-sfn", "axios", "axios-retry"], externalModules: ["aws-sdk", "crypto-js"] },
});

Porting the solution from the comments for posterity:
Do you have mismatched npm CLI versions? AWS CodeBuild tsc error TS2307: Cannot find module.
I understand your project has multiple package.json. In your pipeline ShellStep commands, make sure you are running npm ci for each one to install the dependencies.

Related

How to generate allure report for cucumber js on playwright?

I can not generate allure report for executed features
My package json looks next:
{
"author": "Lorem ipsum",
"description": "Playwright end-to-end test automation with Cucumber",
"devDependencies": {
"#cucumber/cucumber": "^8.5.1",
"#playwright/test": "^1.30.0",
"allure-playwright": "^2.0.0-beta.25",
"cucumber-junit": "^1.5.0",
"cucumberjs-junitxml": "^1.0.0",
"playwright": "^1.24.0",
"jasmine-allure-reporter": "^1.0.2",
"jest-allure": "^0.1.3",
"jasmine":"^3.7.0",
"allure-commandline": "^2.17.2"
},
"keywords": [
"cucumber"
],
"license": "",
"name": "automation",
"repository": {
"type": "git",
"url": ""
},
"scripts": {
"test": "cucumber-js --parallel 1 --tags '#smoke' -f json:report/report.json && node report.js && cat report/report.json | npx cucumber-junit > report/junitreport.xml --publish",
"allure:generate": "npx allure generate ./allure-results --clean",
"allure:open": "npx allure open ./allure-report",
"allure:serve": "npx allure serve"
},
"version": "1.0.0",
"dependencies": {
"cucumber-html-reporter": "^5.3.0",
}
}
I mixed it from all resources what could find.
Have also playwright.config.js in root of folder. It looks next:
const { PlaywrightConfig } = require('#playwright/test');
module.exports = PlaywrightConfig({
reporter: "allure-playwright"
});
But when try to generate report I see NaN. I guess that my test script is not configured properly. Help please with refactor it to run features by tags in couple of threads and with output results for allure.
And dependencies I guess also specified incorrectly (extra or less)

I got "Error: packageJSON.main must be set to a valid entry point for your Electron app" when building with electron forge

I was building with electron forge and then it gave me this error in my terminal.
An unhandled rejection has occurred inside Forge:
Error: packageJSON.main must be set to a valid entry point for your Electron app
Electron Forge was terminated. Location:
{}
My package.json looks like this:
{
"name": "elephant",
"version": "1.0.0",
"description": "my new app",
"main": "main.js",
"scripts": {
"test": "elephant-test",
"start": "electron ."
},
"keywords": [
"editor",
"live-preview",
"html"
],
"author": "unknown",
"license": "MIT",
"devDependencies": {
"electron": "^16.0.7"
}
}
I am unable to resolve this issue. The app works fine when I put in: npm startWhat could I be doing wrong?
Ran into the same problem, for me it worked adding:
"main": "./dist/main.js",
to my package.json, because it's there I was building to.

node modules not found after packaging electron app with electron-forge for window

Electron app was initialized using electron-forge webpack template and everything works perfectly for macOs.
While running the dev version using electron-forge start the app loads perfectly on windows.
Once the app is packaged for windows using electron-forge make the build completes successfully. But while running the packaged app Cannot find module X is thrown.
The folder ./out/app/resources/app/node_modules is empty.
Also the package.json ./out/app/resources/app/package.json looks as follows.
"name": "my-app",
"productName": "my-app",
"version": "1.0.0",
"description": "My Electron application description",
"main": ".webpack/main",
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
"lint": "echo \"No linting configured\""
},
"keywords": [],
"author": {
"name": "",
"email": ""
},
"license": "MIT",
"config": {},
"dependencies": {},
"devDependencies": {},
"optionalDependencies": {},
"peerDependencies": {}
}
None of the dependencies in the source package.json made it to the packaged app.
Try this
cd "my-app"
:: install dependency into your node_modules and update your package.json
npm install your-dependency --save-prod
npm run make

How to Publish to a Private GitHub with Electron-builder NSIS and AppImage?

Electron-builder Version: 20.38.5
Target: Windows ia32 and x64
I'm trying to push the project to GitHub releases in a private repository.
The main target is Win ia32 and x64.
I set the token in the console by:
set GH_TOKEN=<blabla>
And at the package.json file:
"publish": {
"provider": "github",
"repo": "electron-todo-tasks",
"owner": "AndreD23",
"host": "github.com",
"protocol": "https",
"releaseType": "draft",
"token": "<blablabla>",
"private": true
}
I'm the only one who will have access to the project, so updating the token in the file apparently not a problem.
But, when I run:
electron-builder --x64 --ia32 --publish always
It shows me the error:
Error: Cannot cleanup:
Error #1 --------------------------------------------------------------------------------
HttpError: 404 Not Found
"method: undefined url: https://github.com/repos/AndreD23/electron-todo-tasks/releases\n\nPlease double check that your authentication token is correct. Due to security reasons actual status maybe not reported, but 404.\n"
I'll attach the whole error.
2019-03-22T13_04_27_992Z-debug.log
electron publish error.txt
I tried to change the option always to onTag or onTagOrDraft and change releaseType to release.
I tried to manually create a draft on GitHub first, doesn't work.
I tried to make the repository public for tests, not working too.
I tried to regenerate the token twice and updated the envs, console and package.json, doesn't work.
Is there any configuration that I've missed? What I have to do for Electron to publish to GitHub?
At the error, it says that cannot find https://github.com/repos/AndreD23/electron-todo-tasks/releases. Opening it on the web browser, it returns 404. I find the link a bit strange because it adds the word repos after github.com, and removing it in the browser it loads fine. This word is setting automatically?
Thanks #edelCustodio
Reference: https://github.com/electron-userland/electron-builder/issues/3776#issuecomment-486888574
This worked for me, on PowerShell type this
[Environment]::SetEnvironmentVariable("GH_TOKEN","my-personal-token","User")
and be sure that you package.json will be like this:
"build": {
"appId": "com.friasoftit.electron-auto-update",
"productName": "Electron Auto Update",
"publish": [
{
"provider": "github",
"owner": "edelCustodio",
"repo": "electron-auto-update"
}
],
"win": {
"publish": [
"github"
],
"target": [
{
"target": "nsis",
"arch": [
"x64",
"ia32"
]
}
]
}
},
And then I run this command yarn run publish and this is how my publish is on my package.json
"publish": "build --win -p always"
Don't forget to close and open a new PowerShell terminal.
Run windows powerShell from Administrator
Execute [Environment]::SetEnvironmentVariable("GH_TOKEN","<git_hub_token>","User")
Launch or full restart your IDE
Run bozon package windows --publish
Config:
{
"name": "",
"version": "",
"description": "",
"author": "",
"repository": "<repo_url>",
"dependencies": {
"cross-fetch": "^3.0.6",
"electron-builder": "^22.10.5",
"file-loader": "^6.2.0",
"luxon": "^1.26.0",
"node-fetch": "^2.6.1"
},
"license": "ISC",
"devDependencies": {
"bozon": "1.1.3",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.22.1",
"jest": "26.6.3",
"spectron": "13.0.0"
},
"build": {
"appId": "",
"publish": [
{
"provider": "github"
}
],
"win": {}
},
"main": ".eslintrc.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
}
}

Electron-packager does not package node modules which names are started from "#"

I create desktop application by using electron, and tried electron-packager.
But electron-packager doesn't package node modules which names are started from "#" (Example: #turf, #mapbox)
In node_modules folder of developing folder, I can find "#turf" and "#mapbox".
But after running
>electron-packager . MaplatEditor --platform=darwin --arch=x64 --electron-version=1.7.9
Created package never includes "#turf" and "#mapbox".
And also, it's depending modules are also not included.
My package.json includes "#turf", so it is not setting error.
{
"name": "MaplatEditor",
"version": "1.0.0",
"description": "",
"main": "lib/main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#turf/turf": "^4.6.1",
"argv": "0.0.2",
"async": "^2.5.0",
"child_process": "^1.0.2",
"electron-json-storage": "^3.2.0",
"file-url": "^2.0.2",
"fs-extra": "^3.0.1",
"imagemagick": "^0.1.3",
"mapshaper": "^0.4.31",
"path": "^0.12.7",
"wellknown": "^0.5.0"
}
}
How can I package such #-started modules into application package?
In my case, I updated #Turf module for latest version, then electron-packager worked well.
I don't know why, but it looks not the issue of electron-packager...

Resources