Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
The community reviewed whether to reopen this question last year and left it closed:
Original close reason(s) were not resolved
Improve this question
How can I use electron-builder's auto-update feature with Amazon S3 in my electron app?
Maybe someone who has already implemented it, can give more details than those which are provided in the electron-builder documentation?
Yeah I'm agree with you, I've been through there recently...
Even if i'm late, I will try to tell as much as I know for others!
In my case, I'm using electron-builder to package my electron/anguler app.
To use electron-builder, I suggest you to create a file called electron-builder.json at project root.
Thats the content of mine :
{
"productName": "project-name",
"appId": "org.project.project-name",
"artifactName": "${productName}-setup-${version}.${ext}", // this will be the output artifact name
"directories": {
"output": "builds/" // The output directory...
},
"files": [ //included/excluded files
"dist/",
"node_modules/",
"package.json",
"**/*",
"!**/*.ts",
"!*.code-workspace",
"!package-lock.json",
"!src/",
"!e2e/",
"!hooks/",
"!angular.json",
"!_config.yml",
"!karma.conf.js",
"!tsconfig.json",
"!tslint.json"
],
"publish" : {
"provider": "generic",
"url": "https://project-release.s3.amazonaws.com",
"path": "bucket-path"
},
"nsis": {
"oneClick": false,
"allowToChangeInstallationDirectory": true
},
"mac": {
"icon": "src/favicon.ico"
},
"win": {
"icon": "src/favicon.ico"
},
"linux": {
"icon": "src/favicon.png"
}
}
As you can see, you need to add publish config if you want to publish the app automaticly to s3 with electron-buider. The thing I don't like with that, is that all artifacts and files are all located in the same folder. In my case, like you can see in package.json below I decided to package it manually with electron-builder build -p never. This is basically telling never publish it, but I needed it because without it, it would not generate the latest.yml file. I'm using Gitlab-ci to generate the artefacts, then I use a script to publish it on s3, but you can can use -p always option if you want.
Electron-builder need the latest.yml file, because this is how he knoes if the artefact on s3 is more recent.
latest.yml content exemple :
version: 1.0.1
files:
- url: project-setup-1.0.0.exe
sha512: blablablablablablablabla==
size: 72014605
path: project-setup-1.0.0.exe
sha512: blablablablablabla==
releaseDate: '2019-03-10T22:18:19.735Z'
One other important thing to mension is that electron-builder will try to fetch content at the url you provided in electron-builder.json publish config like so :
https://project-release.s3.amazonaws.com/latest.yml
https://project-release.s3.amazonaws.com/project-setup-1.0.0.exe
And this is the default uploaded content
For that, you need to have your s3 bucket public so every one with the app can fetch newest versions...
Here's the policy :
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject",
"s3:GetObjectAcl",
"s3:GetObjectVersion",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::your-bucket-name/*",
"arn:aws:s3:::your-bucket-name"
]
}
]
}
Replace your-bucket-name
Second, to package the app, I added a script to package.json. ("build:prod" for angular only)
"scripts": {
"build:prod": "npm run build -- -c production",
"package:linux": "npm run build:prod && electron-builder build --linux -p never",
"package:windows": "npm run build:prod && electron-builder build --windows -p never",
"package:mac": "npm run build:prod && electron-builder build --mac -p never",
},
Finally, here's a really well written article here that work with gitlab-ci.
I might have forgotten some parts, ask for any questions!
Here is the documentation for S3 autoUpdater in electron-builder
https://www.electron.build/configuration/publish#s3options
You put your configuration inside package.json build tag, for example:
{
"name": "ps-documentation",
"description": "Provides a design pattern for Precisão Sistemas",
"build":{
"publish": {
"provider": "s3",
"bucket": "your-bucket-name"
},
}
}
Related
I have a Node JS server written with ES6 features and use Babel to transpile the code for production. The code itself complies and works fine. I am also able to run my "dev" server and test it locally with this command:
npm run dev
which runs this command inside my package.json:
"dev": "nodemon --exec babel-node ./src/server.js"
Pretty standard so far.
I am having issues with debugging my code so I can use breakpoints. Here's the launch script in my VS Code launch.json file:
{
"name": "Debug",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/src/server.js",
"stopOnEntry": false,
"sourceMaps": true,
"args": [],
"preLaunchTask": null,
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/babel-node",
"runtimeArgs": ["--no-lazy"],
"env": {
"NODE_ENV": "development"
},
"skipFiles": [
"${workspaceFolder}/node_modules/**/*.js",
"<node_internals>/**/*.js"
]
}
And my .babelrc file:
{
"presets": [
[
"#babel/env",
{
"targets": {
"node": "current"
}
}
]
],
"env": {
"development": {
"sourceMaps": "inline",
"retainLines": true
}
},
"comments": true,
"plugins": [
"#babel/plugin-proposal-class-properties",
"#babel/plugin-proposal-object-rest-spread"
]
}
When I try to enter debug mode I get this execption thrown right away:
Exception has occurred: Error: Cannot find module 'kexec'
Require stack:
- F:\Dev\Web Development\****\dev\server\node_modules\#babel\node\lib\babel-node.js
- F:\Dev\Web Development\****\dev\server\node_modules\#babel\node\bin\babel-node.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
at Function.Module._load (node:internal/modules/cjs/loader:804:27)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at F:\Dev\Web Development\****\dev\server\node_modules\#babel\node\lib\babel-node.js:65:68
at processTicksAndRejections (node:internal/process/task_queues:96:5)
This is where is gets really odd. I pulled the same sourcecode to my laptop and debugging worked just fine. I also spun up a sandbox virtual machine on my Windows 10, did a clean install of Node + VS Code on it, and it worked perfectly there too.
There's something in my current environment that is causing this issue and I cannot figure it out. I've been trying to solve this issue for a few days now with no success.
Here are the steps I have already taken:
Upgrade and downgrade versions of Node + NPM and retry using
different versions
Delete node_modules and reinstall with "npm install" (and using npm ci)
Completely uninstall Node and do a fresh install
Removed user and system environemnt variables before the fresh install
Manually delete all NPM caches from %AppData% folder
I also want to point out that when I used a different launch script that is attached to a process ID, I was able to debug the code, but I am trying to streamline this process instead of having to choose the process each time.
This method does work:
npm run dev to start the dev server, which runs this code:
"dev": "nodemon --exec babel-node ./src/server.js"
I then run the debugger and attach it to the running process. Here's the launch script for that:
{
"name": "Attach by Process ID",
"processId": "${command:PickProcess}",
"request": "attach",
"skipFiles": ["<node_internals>/**"],
"type": "node"
}
If kexec is used by Babel, isn't it already supposed to be installed as a dependecy? I couldn't find it anywhere in my modules folder though.
I also tried installing kexec separately but was receiving a lot of node-gyp errors which I tried fixing by reinstalling all of Node build tools using multiple different methods. None of these actions also fixed the issue.
Any ideas or support would tremendously help at this point.
I have a pre-existing project that I'd like to import into my existing lerna monorepo that uses yarn workspaces.
Command(s):
I've tried running all of the following commands. The error remains stubbornly unchanged. Also, petstore has a package.json file and is a git repo.
lerna import ./petstore --dest="./packages/"
lerna import ./petstore --dest="./packages/api/"
ERROR:
lerna notice cli v3.20.2
lerna ERR! EDESTDIR --dest does not match with the package directories: packages/**
Also, lerna import ../petstore results in a packages/**/petstore being created which is not an expected result.
I hope this consists of all the relevant code. We have supporting packages under packages/shared and apis under packages/api.
lerna.json
{
"packages": [
"packages/**/*"
],
"npmClient": "yarn",
"useWorkspaces": true,
"private": true,
"version": "0.0.1",
"lerna": "2.11.0"
}
package.json
{
"name": "root",
"devDependencies": {
"lerna": "^2.11.0"
},
"workspaces": [
"packages/**/*"
],
}
Resources I have looked at:
Lerna troubleshooting page but it does not have any info on this error.
Lerna Github Issue #1872
Lerna Github Issue #1197
Lerna Slack Link Broken
Lerna reads the packages from the key workspaces on package.json instead of the packages on lerna.json.
lerna reads all the values with a /* and considers them package directories. It interprets ** literally and does not parse it as a wildcard and expand it.
The solution is to remove packages from lerna.json:
{
"npmClient": "yarn",
"useWorkspaces": true,
"private": true,
"version": "0.0.1",
"lerna": "2.11.0"
}
and update the workspaces path to refer to any sub-directories in your packages explicitly if your monorepo is structured that way:
{
"name": "root",
"devDependencies": {
"lerna": "^2.11.0"
},
"workspaces": [
"packages/a/*",
"packages/api/*"
],
}
To import the pet-store project into packages/api in the monorepo from a directory outside the mono-repo:
lerna import ../pet-store --dest="./packages/api/"
I'm building a set of microservices that are run on Docker and orchestrated with Kubernetes. I'm building the services in Node.js and so for each service I have a package.json file that has a version. I'd like to use this version when building my docker images, and to keep the build command simple I'd like to have it be a script in package.json. However, I want to keep the version number DRY (i.e. avoid spreading the version number throughout the package.json file, or having any other copies). For example, if I have the following package.json, how could I reference the version in the script to avoid repeating it?
{
"name": "sample-service",
"version": "1.0.0",
"description": "Sample service",
"dependencies": {
...
},
"scripts": {
"docker": "docker build -t prefix/image-name:$version ."
}
}
Obviously, using $version in the tag there doesn't work so is there another way? Just in case it makes a difference, I'm using yarn rather than npm.
Yes First get the version of package.json
Then export the version to the variable so you can access it as a variable.
Here is your package.json
{
"name": "sample-service",
"version": "1.0.0",
"description": "Sample service",
"dependencies": {
},
"scripts": {
"docker": "export version=$(node -e \"console.log(require('./package.json').version)\") || set version=$(node -e \"console.log(require('./package.json').version)\") ; echo version is: $version; docker build -t prefix/image-name:$version ." }
}
If you run this you will get some thing like
I've installed Bootstrap 4 using node into an Angular 2 project by following this guide:
https://github.com/angular/angular-cli/wiki/stories-include-bootstrap
Followed the instructions to the letter, but now when I try and run the application using ng serve I get compile errors.
ERROR in ./node_modules/css-loader?{"sourceMap":false,"importLoaders":1}!./node_modules/postcss-loader/lib?{"ident":"postcss","sourceMap":false}!./node_modules/bootstrap/dist/css/bootstrap.min.css
Module build failed: BrowserslistError: Unknown browser major
at error (D:\GitKracken\KnightOwlUI2018\KOWebUi\node_modules\browserslist\index.js:37:11)
at Function.browserslist.checkName (D:\GitKracken\KnightOwlUI2018\KOWebUi\node_modules\browserslist\index.js:320:18)
at Function.select (D:\GitKracken\KnightOwlUI2018\KOWebUi\node_modules\browserslist\index.js:438:37)
at D:\GitKracken\KnightOwlUI2018\KOWebUi\node_modules\browserslist\index.js:207:41
at Array.forEach (native)
at browserslist (D:\GitKracken\KnightOwlUI2018\KOWebUi\node_modules\browserslist\index.js:196:13)
at Browsers.parse (D:\GitKracken\KnightOwlUI2018\KOWebUi\node_modules\autoprefixer\lib\browsers.js:44:14)
at new Browsers (D:\GitKracken\KnightOwlUI2018\KOWebUi\node_modules\autoprefixer\lib\browsers.js:39:28)
at loadPrefixes (D:\GitKracken\KnightOwlUI2018\KOWebUi\node_modules\autoprefixer\lib\autoprefixer.js:56:18)
at plugin (D:\GitKracken\KnightOwlUI2018\KOWebUi\node_modules\autoprefixer\lib\autoprefixer.js:62:18)
at LazyResult.run (D:\GitKracken\KnightOwlUI2018\KOWebUi\node_modules\postcss-loader\node_modules\postcss\lib\lazy-result.js:277:20)
at LazyResult.asyncTick (D:\GitKracken\KnightOwlUI2018\KOWebUi\node_modules\postcss-loader\node_modules\postcss\lib\lazy-result.js:192:32)
at LazyResult.asyncTick (D:\GitKracken\KnightOwlUI2018\KOWebUi\node_modules\postcss-loader\node_modules\postcss\lib\lazy-result.js:204:22)
at LazyResult.asyncTick (D:\GitKracken\KnightOwlUI2018\KOWebUi\node_modules\postcss-loader\node_modules\postcss\lib\lazy-result.js:204:22)
at processing.Promise.then._this2.processed (D:\GitKracken\KnightOwlUI2018\KOWebUi\node_modules\postcss-loader\node_modules\postcss\lib\lazy-result.js:231:20)
at LazyResult.async (D:\GitKracken\KnightOwlUI2018\KOWebUi\node_modules\postcss-loader\node_modules\postcss\lib\lazy-result.js:228:27)
# ./node_modules/bootstrap/dist/css/bootstrap.min.css 4:14-131
# multi ./node_modules/bootstrap/dist/css/bootstrap.min.css ./src/styles.css
My apps section of my .angular-cli.json file (as far as I can see) seems ok and is the only file I changed since installing Bootstrap 4 and the physical bootstrap files are in the node modules folder. My node_modules folder is in the root of the project on the same level as the src folder just as the cli sets it up by default.
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"styles.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
Have I missed a step somewhere? Or maybe the guide I'm ready is out of date, I'm just not sure, but this feels like it should be really simple and should just work?
Have you seen this bug report?
Basically, two main solutions I get from this:
Try with other minor versions of Bootstrap
Use Sass and import Bootstrap Sass files instead of adding Bootstrap minified CSS in angular-cli.json
Personally I copy the entire Sass code from Bootstrap Github tags into my project. This gives me more flexibility.
I'm using Visual Studio Code 1.13.0 on Windows 10.
I have the following build script in my package.json:
{
//omitted other props
"scripts": {
"build": "webpack"
}
}
I've installed webpack with npm install --global webpack, so it's installed globally.
The webpack.config.js is irrelevant for my question.
When I run npm run build in the terminal, everything works fine. But when I run the Visual Code Tasks: Run Build Task (ctrl+shift+b or ctrl+shift+p > Run Build Task), then I'm getting the following message in the output window:
'"npm run build"' is not recognized as an internal or external
command, operable program or batch file.
Why? (using npm version: 3.10.10)
You should create tasks.json file and specify build task with npm task runner as described here ctrl+shift+p > Configure Task Runner. In your case task.json file should looks something like that
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "npm",
"isShellCommand": true,
"showOutput": "always",
"suppressTaskName": true,
"tasks": [
{
"isBuildCommand": true,
"taskName": "build",
"args": ["run", "build"]
}
]
}
tasks.json can be used for running multiple different tasks. This is #oleg-m's answer updated for version 2 of tasks.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type":"npm",
"script": "build",
"group": "build"
}
]
}