Nicolas BAPTISTA - Blog of a Parisian software architect

This blog contains 44 articles


N I C O L A S    B A P T I S T A



LinkedIn Contact Github Malt More...

AWS Certificate Manager – The SCAM service of AWS

If you are using the services of AWS you should be careful about some services. It is possible that you may want a certificate for your application. You may use free certificate like let’s encrypt but AWS is offering a “Certificate Manager” and you can find it like any other services:

400$/month per private certificate

But, on the pricing page, you can find that this service cost 400$/month, no matter if you use it or not, it will take you the price of renting a car.

No way to delete or stop this recurring amount of money from the account

On the documentation, you can find that the service will stop “until you delete the CA”. I can tell you that this information is not really true as this service still take money without the CA. So additionally this service have a very not predictable way of taking money, and you don’t really know when it will stop, even if you check there is no certificate and you read carefully the documentation.

Git : Don’t commit node_modules except a file in a library

If you are using the node_modules in your Node.JS / Javascript / Typescript project you should exclude to commit all the libraries used by your application with this line in the .gitignore file:



But, you may need to modify a file in the /node_modules folder, excluded in the .gitignore

Force commit a file in a excluded folder in .gitignore

If you want to fix a file in a library that makes some problems in your application, you may want to modify the library directly in /node_modules (the case you are using the last version of the library, you can check on if you are using the last version in your package.json)

In my case, I modified node_modules/react-native-firebase/ios/RNFirebase/notifications/RNFirebaseNotifications.m a library that is not changed since 2 years and have a problem in my application. You can of course make a git issue on the official page but if you need it to work fast, you may want to commit it directly in your project and it is fixed.

After you made the change in the library, you can commit with git add -f …

In my case:

git add -f node_modules/react-native-firebase/ios/RNFirebase/notifications/RNFirebaseNotifications.m
You can see your file to be commit in your Git Desktop, and my node_modules folder is excluded in .gitignore

How to remove git token on git project after a failed git pull

After doing a git pull is it possible you have an error because your Git Token is not valid anymore, here is an exemple:

# git pull
remote: HTTP Basic: Access denied
fatal: Authentication failed for ''

In order to do the git pull we want to use our credential with the LOGIN / PASSWORD that we use to access GitLab.

Solution 1 : Git pull one time with login (temporary)

# git pull

Solution 2 : Change the origin URL to HTTPS (permanent)

# git remote set-url origin
# git pull

It will ask your login and password for the git pull and will not use the git token anymore.

Kill Node.JS service by port / Arrêter un service Node.JS avec son port

🇬🇧Dear all, is it possible you want to kill a Node.JS service with your linux machine, that is running on a specific port

Il est possible que vous voulez arrêter un processus Node.JS sur un port précis sur votre machine linux🇫🇷

Here is the magic command to find and kill the Node.JS process

Voici la commande magique qui permet de trouver et arrêter de processus avec son port

netstat -pluton
It looks like the name of the famous planet / Moyen mémo-technique on pense à cette p’tite planete

Then you should be able to find the process (PID) with the port associated

Vous devriez avec cette commande trouver le nom du processus (PID) avec le port associé

PORT 4000:

React native with Android – Fix : Device unauthorized

Check developer is enabled in the phone settings

One reason your phone is not detected is that you don’t have enabled the developer mode in the Android Settings.

Check the connected android devices with adb devices

Now you can check if your phone is connected with adb devices

sh-3.2# adb devices
* daemon not running; starting now at tcp:5037
* daemon started successfully
List of devices attached
CBAA004484J41536762     unauthorized

Authorise your device with adb kill-server and adb devices

If your phone still not asking anything while connected, you can force the adb service to restart like that:

sh-3.2# adb kill-server
sh-3.2# adb devices
* daemon not running; starting now at tcp:5037
* daemon started successfully

Then now you should be able to see a message on your phone asking if you authorise the computer.
Now you should be able to do your react-native run-android or yarn android

Start Google Cloud instance VM from a shared image from another Project / Organization

If you have multiple projects or organization and you want to clone a machine that is already configured, you can create an image of the instance of the machine.
But, you will have to share the access to the external project and organization.
Here is how to do it :

Share the image to the organization in the Images and in IAM

In both IAM and Image (VM) you will have to share the access Compute Image User

Start the VM using the shared image from another project / organization

gcloud compute instances create INSTANCE-NAME --image SHARED-IMAGE-NAME --image-project PROJECT-NAME --zone ZONE --tags http-server
  • INSTANCE-NAME : Name of the VM instance you are creating (that will appear in the VM list)
  • SHARED-IMAGE-NAME : The name of the image you shared to the organization
  • PROJECT-NAME : The name if the project where is the image you shared to the organization
  • ZONE : The geographical zone of the VM

Now the machine is started from an image from another organization and project !

Mac M1 : react native iOS mobile app on Simulator

I decided to make an article because I spent almost 5 days on this problem, and I don’t want it never happen. So let me help all the people that can be in the same case of me.

– You have a Mac M1 running on ARM 64 architecture
– You are working on a React Native or Swift project with Xcode

Exclude the ARM architecture in the Podfile

Add the following lines in the Podfile (/ios/Podfile) :

    post_install do |installer|
      ## FIX MAC M1 ARM
      installer.pods_project.build_configurations.each do |config|
        config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"

You should check that there is only one “post_install” in the file, if there is not you can add it at the end of the file, if there is already “post_install” somewhere, just put the instructions to exclude the architecture ARM 64 at the end of the “post_install” section.

Dependencies with CocoaPods

In the /ios folder of your React Native project, you should run the following command to build all the dependancy in the /Pods folder :

sudo arch -x86_64 pod install --allow-root

or, you can also use pod-install to be sure all is installed:

npx pod-install

In case of error: Delete /Pods folder, delete Podfile.lock and start again. In case of error of dependancies in node_modules, delete node_modules and run yarn.

Exclude the ARM architecture in Xcode

Now, you should also exclude the architecture in the project settings in Xcode :

Exclude the architecture “arm64” in Project > Build Settings > Architectures

Then if you start the react native project on Simulator it should works !

How to solve error SQL Import Google Cloud

error: exit status 1 stdout(capped at 100k bytes): stderr: ERROR 3546 (HY000) at line 26: @@GLOBAL.GTID_PURGED cannot be changed: the added gtid set must not overlap with @@GLOBAL.GTID_EXECUTED

To solve the problem, open the SQL file with text editor and search the error “@@GLOBAL.GTID_EXECUTED”

It should now work

Renew automatically HTTPS SSL certificates with cron and Certbot

Use the command crontab -e to edit the crontab (recurring tasks), and insert the following line:

0 0 1 * * /usr/bin/certbot renew --pre-hook “service nginx stop” --post-hook “service nginx start” --quiet > /etc/letsencrypt/renewals.log

It will renew all the certificates, the 1st of each month (0 0 1 * *), and will stop nginx before the renewal and start nginx after the renewal so it can works.
It will work on all the linux servers.

AWS Amplify : Babel error building React.JS app

Is it possible you may have an error with babel on AWS Amplify, while deploying your React.JS app:

If you click on Frontend you should be able to see the logs :

2022-01-14T17:18:36.441Z [INFO]: $ react-scripts build
2022-01-14T17:18:37.352Z [INFO]: Creating an optimized production build...
2022-01-14T17:18:38.431Z [INFO]: Failed to compile.
2022-01-14T17:18:38.433Z [INFO]: ./src/index.js
                                 Error: [BABEL] /codebuild/output/src483533555/src/app/src/index.js: Cannot find module '@babel/helper-define-map'
                                 Require stack:
                                 - /codebuild/output/src483533555/src/app/node_modules/babel-preset-react-app/node_modules/@babel/plugin-transform-classes/lib/transformClass.js
                                 - /codebuild/output/src483533555/src/app/node_modules/babel-preset-react-app/node_modules/@babel/plugin-transform-classes/lib/index.js
                                 - /codebuild/output/src483533555/src/app/node_modules/babel-preset-react-app/node_modules/@babel/preset-env/lib/available-plugins.js
                                 - /codebuild/output/src483533555/src/app/node_modules/babel-preset-react-app/node_modules/@babel/preset-env/lib/plugins-compat-data.js
                                 - /codebuild/output/src483533555/src/app/node_modules/babel-preset-react-app/node_modules/@babel/preset-env/lib/normalize-options.js
                                 - /codebuild/output/src483533555/src/app/node_modules/babel-preset-react-app/node_modules/@babel/preset-env/lib/index.js
                                 - /codebuild/output/src483533555/src/app/node_modules/babel-preset-react-app/create.js
                                 - /codebuild/output/src483533555/src/app/node_modules/babel-preset-react-app/index.js
                                 - /codebuild/output/src483533555/src/app/node_modules/react-scripts/node_modules/@babel/core/lib/config/files/plugins.js
                                 - /codebuild/output/src483533555/src/app/node_modules/react-scripts/node_modules/@babel/core/lib/config/files/index.js
                                 - /codebuild/output/src483533555/src/app/node_modules/react-scripts/node_modules/@babel/core/lib/index.js
                                 - /codebuild/output/src483533555/src/app/node_modules/react-scripts/node_modules/babel-loader/lib/index.js
                                 - /codebuild/output/src483533555/src/app/node_modules/loader-runner/lib/loadLoader.js
                                 - /codebuild/output/src483533555/src/app/node_modules/loader-runner/lib/LoaderRunner.js
                                 - /codebuild/output/src483533555/src/app/node_modules/webpack/lib/NormalModule.js
                                 - /codebuild/output/src483533555/src/app/node_modules/webpack/lib/NormalModuleFactory.js
                                 - /codebuild/output/src483533555/src/app/node_modules/webpack/lib/Compiler.js
                                 - /codebuild/output/src483533555/src/app/node_modules/webpack/lib/webpack.js
                                 - /codebuild/output/src483533555/src/app/node_modules/react-scripts/scripts/build.js (While processing: "/codebuild/output/src483533555/src/app/node_modules/babel-preset-react-app/index.js")
2022-01-14T17:18:38.451Z [WARNING]: error Command failed with exit code 1.
2022-01-14T17:18:38.451Z [INFO]: info Visit for documentation about this command.
2022-01-14T17:18:38.461Z [ERROR]: !!! Build failed
2022-01-14T17:18:38.461Z [ERROR]: !!! Non-Zero Exit Code detected
2022-01-14T17:18:38.461Z [INFO]: # Starting environment caching...
2022-01-14T17:18:38.461Z [INFO]: # Uploading environment cache artifact...
2022-01-14T17:18:38.534Z [INFO]: # Environment caching completed
Terminating logging...

In order to solve the @babel errors, you will need to install all the @babel packages:


npm install babel-core babel-loader babel-preset-env 
babel-preset-react babel-polyfill babel-runtime @babel/helpers 
@babel/helper-builder-react-jsx-experimental @babel/helper-builder-react-jsx 
@babel/helper-define-map @babel/helper-plugin-utils @babel/helper-regex


yarn add babel-core babel-loader babel-preset-env 
babel-preset-react babel-polyfill babel-runtime @babel/helpers 
@babel/helper-builder-react-jsx-experimental @babel/helper-builder-react-jsx 
@babel/helper-define-map @babel/helper-plugin-utils @babel/helper-regex

In order to run your React.JS project on Amplify, here is all the babel packages I installed to solve all problems:

  • babel-core
  • babel-loader
  • babel-preset-env
  • babel-preset-react
  • babel-polyfill
  • babel-runtime
  • @babel/helpers
  • @babel/helper-builder-react-jsx
  • @babel/helper-builder-react-jsx-experimental
  • @babel/helper-define-map
  • @babel/helper-plugin-utils
  • @babel/helper-regex

After, that, you should be able to see your React.JS app online with Amplify: