Hi I'm trying to install Chatwoot from scratch using Linux in Digital ocean. I have the same repository in my git and I change the line that I have on "install.sh" and just replace the repository url and after the instalation was success I have "502 bad gateway" this is my install.sh file. Could you help me please?
#!/usr/bin/env bash
# Description: Install and manage a Chatwoot installation.
# OS: Ubuntu 20.04 LTS
# Script Version: 2.2.0
# Run this script as root
set -eu -o errexit -o pipefail -o noclobber -o nounset
# -allow a command to fail with !’s side effect on errexit
# -use return value from ${PIPESTATUS[0]}, because ! hosed $?
! getopt --test > /dev/null
if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
echo '`getopt --test` failed in this environment.'
exit 1
fi
# Global variables
# option --output/-o requires 1 argument
LONGOPTS=console,debug,help,install,Install:,logs:,restart,ssl,upgrade,webserver,version
OPTIONS=cdhiI:l:rsuwv
CWCTL_VERSION="2.2.0"
pg_pass=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 15 ; echo '')
# if user does not specify an option
if [ "$#" -eq 0 ]; then
echo "No options specified. Use --help to learn more."
exit 1
fi
# -regarding ! and PIPESTATUS see above
# -temporarily store output to be able to check for errors
# -activate quoting/enhanced mode (e.g. by writing out “--optionsâ€)
# -pass arguments only via -- "$#" to separate them correctly
! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$#")
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
# e.g. return value is 1
# then getopt has complained about wrong arguments to stdout
exit 2
fi
# read getopt’s output this way to handle the quoting right:
eval set -- "$PARSED"
c=n d=n h=n i=n I=n l=n r=n s=n u=n w=n v=n BRANCH=master SERVICE=web
# Iterate options in order and nicely split until we see --
while true; do
case "$1" in
-c|--console)
c=y
break
;;
-d|--debug)
d=y
shift
;;
-h|--help)
h=y
break
;;
-i|--install)
i=y
BRANCH="master"
break
;;
-I|--Install)
I=y
BRANCH="$2"
break
;;
-l|--logs)
l=y
SERVICE="$2"
break
;;
-r|--restart)
r=y
break
;;
-s|--ssl)
s=y
shift
;;
-u|--upgrade)
u=y
break
;;
-w|--webserver)
w=y
shift
;;
-v|--version)
v=y
shift
;;
--)
shift
break
;;
*)
echo "Invalid option(s) specified. Use help(-h) to learn more."
exit 3
;;
esac
done
# log if debug flag set
if [ "$d" == "y" ]; then
echo "console: $c, debug: $d, help: $h, install: $i, Install: $I, BRANCH: $BRANCH, \
logs: $l, SERVICE: $SERVICE, ssl: $s, upgrade: $u, webserver: $w"
fi
# exit if script is not run as root
if [ "$(id -u)" -ne 0 ]; then
echo 'This needs to be run as root.' >&2
exit 1
fi
trap exit_handler EXIT
##############################################################################
# Invoked upon EXIT signal from bash
# Upon non-zero exit, notifies the user to check log file.
# Globals:
# None
# Arguments:
# None
# Outputs:
# None
##############################################################################
function exit_handler() {
if [ "$?" -ne 0 ] && [ "$u" == "n" ]; then
echo -en "\nSome error has occured. Check '/var/log/chatwoot-setup.log' for details.\n"
exit 1
fi
}
##############################################################################
# Read user input related to domain setup
# Globals:
# domain_name
# le_email
# Arguments:
# None
# Outputs:
# None
##############################################################################
function get_domain_info() {
read -rp 'Enter the domain/subdomain for Chatwoot (e.g., chatwoot.domain.com): ' domain_name
read -rp 'Enter an email address for LetsEncrypt to send reminders when your SSL certificate is up for renewal: ' le_email
cat << EOF
This script will generate SSL certificates via LetsEncrypt and
serve Chatwoot at https://$domain_name.
Proceed further once you have pointed your DNS to the IP of the instance.
EOF
read -rp 'Do you wish to proceed? (yes or no): ' exit_true
if [ "$exit_true" == "no" ]; then
exit 1
fi
}
##############################################################################
# Install common dependencies
# Globals:
# None
# Arguments:
# None
# Outputs:
# None
##############################################################################
function install_dependencies() {
apt update && apt upgrade -y
apt install -y curl
curl -sL https://deb.nodesource.com/setup_12.x | bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
apt update
apt install -y \
git software-properties-common imagemagick libpq-dev \
libxml2-dev libxslt1-dev file g++ gcc autoconf build-essential \
libssl-dev libyaml-dev libreadline-dev gnupg2 \
postgresql-client redis-tools \
nodejs yarn patch ruby-dev zlib1g-dev liblzma-dev \
libgmp-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev sudo
}
##############################################################################
# Install postgres and redis
# Globals:
# None
# Arguments:
# None
# Outputs:
# None
##############################################################################
function install_databases() {
apt install -y postgresql postgresql-contrib redis-server
}
##############################################################################
# Install nginx and cerbot for LetsEncrypt
# Globals:
# None
# Arguments:
# None
# Outputs:
# None
##############################################################################
function install_webserver() {
apt install -y nginx nginx-full certbot python3-certbot-nginx
}
##############################################################################
# Create chatwoot linux user
# Globals:
# None
# Arguments:
# None
# Outputs:
# None
##############################################################################
function create_cw_user() {
if ! id -u "chatwoot"; then
adduser --disabled-login --gecos "" chatwoot
fi
}
##############################################################################
# Install rvm(ruby version manager)
# Globals:
# None
# Arguments:
# None
# Outputs:
# None
##############################################################################
function configure_rvm() {
create_cw_user
gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg2 --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable
adduser chatwoot rvm
}
##############################################################################
# Save the pgpass used to setup postgres
# Globals:
# None
# Arguments:
# None
# Outputs:
# None
##############################################################################
function save_pgpass() {
mkdir -p /opt/chatwoot/config
file="/opt/chatwoot/config/.pg_pass"
if ! test -f "$file"; then
echo $pg_pass > /opt/chatwoot/config/.pg_pass
fi
}
##############################################################################
# Get the pgpass used to setup postgres if installation fails midway
# and needs to be re-run
# Globals:
# pg_pass
# Arguments:
# None
# Outputs:
# None
##############################################################################
function get_pgpass() {
file="/opt/chatwoot/config/.pg_pass"
if test -f "$file"; then
pg_pass=$(cat $file)
fi
}
##############################################################################
# Configure postgres to create chatwoot db user.
# Enable postgres and redis systemd services.
# Globals:
# None
# Arguments:
# None
# Outputs:
# None
##############################################################################
function configure_db() {
save_pgpass
get_pgpass
sudo -i -u postgres psql << EOF
\set pass `echo $pg_pass`
CREATE USER chatwoot CREATEDB;
ALTER USER chatwoot PASSWORD :'pass';
ALTER ROLE chatwoot SUPERUSER;
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
DROP DATABASE template1;
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
\c template1
VACUUM FREEZE;
EOF
systemctl enable redis-server.service
systemctl enable postgresql
}
##############################################################################
# Install Chatwoot
# This includes setting up ruby, cloning repo and installing dependencies.
# Globals:
# pg_pass
# Arguments:
# None
# Outputs:
# None
##############################################################################
function setup_chatwoot() {
local secret=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 63 ; echo '')
local RAILS_ENV=production
get_pgpass
sudo -i -u chatwoot << EOF
rvm --version
rvm autolibs disable
rvm install "ruby-3.0.4"
rvm use 3.0.4 --default
git clone https://github.com/mssnzz/chatwoot.git
cd chatwoot
git checkout "$BRANCH"
bundle
yarn
cp .env.example .env
sed -i -e "/SECRET_KEY_BASE/ s/=.*/=$secret/" .env
sed -i -e '/REDIS_URL/ s/=.*/=redis:\/\/localhost:6379/' .env
sed -i -e '/POSTGRES_HOST/ s/=.*/=localhost/' .env
sed -i -e '/POSTGRES_USERNAME/ s/=.*/=chatwoot/' .env
sed -i -e "/POSTGRES_PASSWORD/ s/=.*/=$pg_pass/" .env
sed -i -e '/RAILS_ENV/ s/=.*/=$RAILS_ENV/' .env
echo -en "\nINSTALLATION_ENV=linux_script" >> ".env"
rake assets:precompile RAILS_ENV=production
EOF
}
##############################################################################
# Run database migrations.
# Globals:
# None
# Arguments:
# None
# Outputs:
# None
##############################################################################
function run_db_migrations(){
sudo -i -u chatwoot << EOF
cd chatwoot
RAILS_ENV=production bundle exec rails db:chatwoot_prepare
EOF
}
##############################################################################
# Setup Chatwoot systemd services and cwctl CLI
# Globals:
# None
# Arguments:
# None
# Outputs:
# None
##############################################################################
function configure_systemd_services() {
cp /home/chatwoot/chatwoot/deployment/chatwoot-web.1.service /etc/systemd/system/chatwoot-web.1.service
cp /home/chatwoot/chatwoot/deployment/chatwoot-worker.1.service /etc/systemd/system/chatwoot-worker.1.service
cp /home/chatwoot/chatwoot/deployment/chatwoot.target /etc/systemd/system/chatwoot.target
cp /home/chatwoot/chatwoot/deployment/chatwoot /etc/sudoers.d/chatwoot
cp /home/chatwoot/chatwoot/deployment/setup_20.04.sh /usr/local/bin/cwctl
chmod +x /usr/local/bin/cwctl
systemctl enable chatwoot.target
systemctl start chatwoot.target
}
##############################################################################
# Fetch and install SSL certificates from LetsEncrypt
# Modify the nginx config and restart nginx.
# Also modifies FRONTEND_URL in .env file.
# Globals:
# None
# Arguments:
# domain_name
# le_email
# Outputs:
# None
##############################################################################
function setup_ssl() {
if [ "$d" == "y" ]; then
echo "debug: setting up ssl"
echo "debug: domain: $domain_name"
echo "debug: letsencrypt email: $le_email"
fi
curl https://ssl-config.mozilla.org/ffdhe4096.txt >> /etc/ssl/dhparam
wget https://raw.githubusercontent.com/chatwoot/chatwoot/develop/deployment/nginx_chatwoot.conf
cp nginx_chatwoot.conf /etc/nginx/sites-available/nginx_chatwoot.conf
certbot certonly --non-interactive --agree-tos --nginx -m "$le_email" -d "$domain_name"
sed -i "s/chatwoot.domain.com/$domain_name/g" /etc/nginx/sites-available/nginx_chatwoot.conf
ln -s /etc/nginx/sites-available/nginx_chatwoot.conf /etc/nginx/sites-enabled/nginx_chatwoot.conf
systemctl restart nginx
sudo -i -u chatwoot << EOF
cd chatwoot
sed -i "s/http:\/\/0.0.0.0:3000/https:\/\/$domain_name/g" .env
EOF
systemctl restart chatwoot.target
}
##############################################################################
# Setup logging
# Globals:
# LOG_FILE
# Arguments:
# None
# Outputs:
# None
##############################################################################
function setup_logging() {
touch /var/log/chatwoot-setup.log
LOG_FILE="/var/log/chatwoot-setup.log"
}
function ssl_success_message() {
cat << EOF
***************************************************************************
Woot! Woot!! Chatwoot server installation is complete.
The server will be accessible at https://$domain_name
Join the community at https://chatwoot.com/community?utm_source=cwctl
***************************************************************************
EOF
}
function cwctl_message() {
echo $'\U0001F680 Try out the all new Chatwoot CLI tool to manage your installation.'
echo $'\U0001F680 Type "cwctl --help" to learn more.'
}
##############################################################################
# This function handles the installation(-i/--install)
# Globals:
# CW_VERSION
# Arguments:
# None
# Outputs:
# None
##############################################################################
function get_cw_version() {
CW_VERSION=$(curl -s https://app.chatwoot.com/api | python3 -c 'import sys,json;data=json.loads(sys.stdin.read()); print(data["version"])')
}
##############################################################################
# This function handles the installation(-i/--install)
# Globals:
# configure_webserver
# install_pg_redis
# Arguments:
# None
# Outputs:
# None
##############################################################################
function install() {
get_cw_version
cat << EOF
***************************************************************************
Chatwoot Installation (v$CW_VERSION)
***************************************************************************
For more verbose logs, open up a second terminal and follow along using,
'tail -f /var/log/chatwoot-setup.log'.
EOF
sleep 3
read -rp 'Would you like to configure a domain and SSL for Chatwoot?(yes or no): ' configure_webserver
if [ "$configure_webserver" == "yes" ]; then
get_domain_info
fi
echo -en "\n"
read -rp 'Would you like to install Postgres and Redis? (Answer no if you plan to use external services): ' install_pg_redis
echo -en "\n➥ 1/9 Installing dependencies. This takes a while.\n"
install_dependencies &>> "${LOG_FILE}"
if [ "$install_pg_redis" != "no" ]; then
echo "➥ 2/9 Installing databases."
install_databases &>> "${LOG_FILE}"
else
echo "➥ 2/9 Skipping Postgres and Redis installation."
fi
if [ "$configure_webserver" == "yes" ]; then
echo "➥ 3/9 Installing webserver."
install_webserver &>> "${LOG_FILE}"
else
echo "➥ 3/9 Skipping webserver installation."
fi
echo "➥ 4/9 Setting up Ruby"
configure_rvm &>> "${LOG_FILE}"
if [ "$install_pg_redis" != "no" ]; then
echo "➥ 5/9 Setting up the database."
configure_db &>> "${LOG_FILE}"
else
echo "➥ 5/9 Skipping database setup."
fi
echo "➥ 6/9 Installing Chatwoot. This takes a long while."
setup_chatwoot &>> "${LOG_FILE}"
if [ "$install_pg_redis" != "no" ]; then
echo "➥ 7/9 Running database migrations."
run_db_migrations &>> "${LOG_FILE}"
else
echo "➥ 7/9 Skipping database migrations."
fi
echo "➥ 8/9 Setting up systemd services."
configure_systemd_services &>> "${LOG_FILE}"
public_ip=$(curl http://checkip.amazonaws.com -s)
if [ "$configure_webserver" != "yes" ]
then
cat << EOF
➥ 9/9 Skipping SSL/TLS setup.
***************************************************************************
Woot! Woot!! Chatwoot server installation is complete.
The server will be accessible at http://$public_ip:3000
To configure a domain and SSL certificate, follow the guide at
https://www.chatwoot.com/docs/deployment/deploy-chatwoot-in-linux-vm?utm_source=cwctl
Join the community at https://chatwoot.com/community?utm_source=cwctl
***************************************************************************
EOF
cwctl_message
else
echo "➥ 9/9 Setting up SSL/TLS."
setup_ssl &>> "${LOG_FILE}"
ssl_success_message
cwctl_message
fi
if [ "$install_pg_redis" == "no" ]
then
cat <<EOF
***************************************************************************
The database migrations had not run as Postgres and Redis were not installed
as part of the installation process. After modifying the environment
variables (in the .env file) with your external database credentials, run
the database migrations using the below command.
'RAILS_ENV=production bundle exec rails db:chatwoot_prepare'.
***************************************************************************
EOF
cwctl_message
fi
exit 0
}
##############################################################################
# Access ruby console (-c/--console)
# Globals:
# None
# Arguments:
# None
# Outputs:
# None
##############################################################################
function get_console() {
sudo -i -u chatwoot bash -c " cd chatwoot && RAILS_ENV=production bundle exec rails c"
}
##############################################################################
# Prints the help message (-c/--console)
# Globals:
# None
# Arguments:
# None
# Outputs:
# None
##############################################################################
function help() {
cat <<EOF
Usage: cwctl [OPTION]...
Install and manage your Chatwoot installation.
Example: cwctl -i master
Example: cwctl -l web
Example: cwctl --logs worker
Example: cwctl --upgrade
Example: cwctl -c
Installation/Upgrade:
-i, --install Install the latest stable version of Chatwoot
-I Install Chatwoot from a git branch
-u, --upgrade Upgrade Chatwoot to the latest stable version
-s, --ssl Fetch and install SSL certificates using LetsEncrypt
-w, --webserver Install and configure Nginx webserver with SSL
Management:
-c, --console Open ruby console
-l, --logs View logs from Chatwoot. Supported values include web/worker.
-r, --restart Restart Chatwoot server
Miscellaneous:
-d, --debug Show debug messages
-v, --version Display version information
-h, --help Display this help text
Exit status:
Returns 0 if successful; non-zero otherwise.
Report bugs at https://github.com/chatwoot/chatwoot/issues
Get help, https://chatwoot.com/community?utm_source=cwctl
EOF
}
##############################################################################
# Get Chatwoot web/worker logs (-l/--logs)
# Globals:
# None
# Arguments:
# None
# Outputs:
# None
##############################################################################
function get_logs() {
if [ "$SERVICE" == "worker" ]; then
journalctl -u chatwoot-worker.1.service -f
fi
if [ "$SERVICE" == "web" ]; then
journalctl -u chatwoot-web.1.service -f
fi
}
##############################################################################
# Setup SSL (-s/--ssl)
# Installs nginx if not available.
# Globals:
# domain_name
# le_email
# Arguments:
# None
# Outputs:
# None
##############################################################################
function ssl() {
if [ "$d" == "y" ]; then
echo "Setting up ssl"
fi
get_domain_info
if ! systemctl -q is-active nginx; then
install_webserver
fi
setup_ssl
ssl_success_message
}
##############################################################################
# Abort upgrade if custom code changes detected(-u/--upgrade)
# Globals:
# None
# Arguments:
# None
# Outputs:
# None
##############################################################################
function upgrade_prereq() {
sudo -i -u chatwoot << "EOF"
cd chatwoot
git update-index --refresh
git diff-index --quiet HEAD --
if [ "$?" -eq 1 ]; then
echo "Custom code changes detected. Aborting update."
echo "Please proceed to update manually."
exit 1
fi
EOF
}
##############################################################################
# Upgrade an existing installation to latest stable version(-u/--upgrade)
# Globals:
# None
# Arguments:
# None
# Outputs:
# None
##############################################################################
function upgrade() {
get_cw_version
echo "Upgrading Chatwoot to v$CW_VERSION"
sleep 3
upgrade_prereq
sudo -i -u chatwoot << "EOF"
# Navigate to the Chatwoot directory
cd chatwoot
# Pull the latest version of the master branch
git checkout master && git pull
# Ensure the ruby version is upto date
# Parse the latest ruby version
latest_ruby_version="$(cat '.ruby-version')"
rvm install "ruby-$latest_ruby_version"
rvm use "$latest_ruby_version" --default
# Update dependencies
bundle
yarn
# Recompile the assets
rake assets:precompile RAILS_ENV=production
# Migrate the database schema
RAILS_ENV=production bundle exec rake db:migrate
EOF
# Copy the updated targets
cp /home/chatwoot/chatwoot/deployment/chatwoot-web.1.service /etc/systemd/system/chatwoot-web.1.service
cp /home/chatwoot/chatwoot/deployment/chatwoot-worker.1.service /etc/systemd/system/chatwoot-worker.1.service
cp /home/chatwoot/chatwoot/deployment/chatwoot.target /etc/systemd/system/chatwoot.target
cp /home/chatwoot/chatwoot/deployment/chatwoot /etc/sudoers.d/chatwoot
# TODO:(#vn) handle cwctl updates
systemctl daemon-reload
# Restart the chatwoot server
systemctl restart chatwoot.target
}
##############################################################################
# Restart Chatwoot server (-r/--restart)
# Globals:
# None
# Arguments:
# None
# Outputs:
# None
##############################################################################
function restart() {
systemctl restart chatwoot.target
systemctl status chatwoot.target
}
##############################################################################
# Install nginx and setup SSL (-w/--webserver)
# Globals:
# domain_name
# le_email
# Arguments:
# None
# Outputs:
# None
##############################################################################
function webserver() {
if [ "$d" == "y" ]; then
echo "Installing nginx"
fi
ssl
#TODO(#vn): allow installing nginx only without SSL
}
##############################################################################
# Print cwctl version (-v/--version)
# Globals:
# None
# Arguments:
# None
# Outputs:
# None
##############################################################################
function version() {
echo "cwctl v$CWCTL_VERSION alpha build"
}
##############################################################################
# main function that handles the control flow
# Globals:
# None
# Arguments:
# None
# Outputs:
# None
##############################################################################
function main() {
setup_logging
if [ "$c" == "y" ]; then
get_console
fi
if [ "$h" == "y" ]; then
help
fi
if [ "$i" == "y" ] || [ "$I" == "y" ]; then
install
fi
if [ "$l" == "y" ]; then
get_logs
fi
if [ "$r" == "y" ]; then
restart
fi
if [ "$s" == "y" ]; then
ssl
fi
if [ "$u" == "y" ]; then
upgrade
fi
if [ "$w" == "y" ]; then
webserver
fi
if [ "$v" == "y" ]; then
version
fi
}
main "$#"
Ok so I am assuming you are deploying your solution according to the documentation provided here
And with respect to the script you have attached you are deploying the solution on a virtual machine with a straight script install.
Then in this case you need to check 2-3 things
If you are using some external Postgres or Redis server then you need to provide respective credentials in the .env file.
External Postgres with SSL enabled is not currently supported by chatwoot.
Check the worker logs for errors and warning respect to the connection with databases.
To check the worker logs use this command if you have installed cwctl.
cwctl -l worker
Also to check the web logs use this
cwctl -l web
If you are using external redis and there are errors with connection check the port and creds also sometimes external redis providers on the cloud like Google and Amazon block some of the redis commands so try once with local redis.
If the above things are fine and the connection with DB is good then you probably not have created DB migrations of your Postgres DB.
To Do, DB Migration run these commands inside the chatwoot directory.
rails db:chatwoot_prepare
rails db:migrate
After successful DB migration it should work correctly.
Note - You have to run DB migration commands the first time after the successful installation.
If all the above things are completed successfully and there are no errors.
Then there are some chances that your loadbalancer is not set correctly or some health check is failing. Kindly check that and fix it.
Cheers WOOT WOOT!
This happens when nginx cannot route the requests to your rails server. Please check if the Chatwoot web server is running.
systemctl status chatwoot.target
To restart,
cwctl --restart
Related
I want to use my mock servers for my stories. The Storybook runs perfectly. Once I go through the steps of adding msw-storybook-addon and set up my preview.js from here and here (preview.js is different in these two resources, I tried both), and I run
start-storybook -p 9009 -s public
I get the error below:
ERROR in ./node_modules/strict-event-emitter/lib/Emitter.js 14:4
Module parse failed: Unexpected character '#' (14:4)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| */
| class Emitter {
> #events;
| #maxListeners;
| #hasWarnedAboutPotentialMemortyLeak;
# ./node_modules/strict-event-emitter/lib/index.js 17:13-33
# ./node_modules/msw/lib/index.js
# ./src/mocks/browser.ts
# ./.storybook/preview.js
# ./.storybook/preview.js-generated-config-entry.js
# multi ./node_modules/#storybook/core-client/dist/esm/globals/polyfills.js ./node_modules/#storybook/core-client/dist/esm/globals/globals.js ./node_modules/webpack-hot-middleware/client.js?reload=true&quiet=false&noInfo=undefined ./storybook-init-framework-entry.js ./node_modules/#storybook/react/dist/esm/client/docs/config-generated-config-entry.js ./node_modules/#storybook/react/dist/esm/client/preview/config-generated-config-entry.js ./node_modules/#storybook/addon-actions/preview.js-generated-config-entry.js ./node_modules/#storybook/addon-interactions/preview.js-generated-config-entry.js ./.storybook/preview.js-generated-config-entry.js ./generated-stories-entry.js
ERROR in ./node_modules/strict-event-emitter/lib/MemoryLeakError.js 5:11
Module parse failed: Unexpected token (5:11)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| exports.MemoryLeakError = void 0;
| class MemoryLeakError extends Error {
> emitter;
| type;
| count;
# ./node_modules/strict-event-emitter/lib/index.js 18:13-41
# ./node_modules/msw/lib/index.js
# ./src/mocks/browser.ts
# ./.storybook/preview.js
# ./.storybook/preview.js-generated-config-entry.js
# multi ./node_modules/#storybook/core-client/dist/esm/globals/polyfills.js ./node_modules/#storybook/core-client/dist/esm/globals/globals.js ./node_modules/webpack-hot-middleware/client.js?reload=true&quiet=false&noInfo=undefined ./storybook-init-framework-entry.js ./node_modules/#storybook/react/dist/esm/client/docs/config-generated-config-entry.js ./node_modules/#storybook/react/dist/esm/client/preview/config-generated-config-entry.js ./node_modules/#storybook/addon-actions/preview.js-generated-config-entry.js ./node_modules/#storybook/addon-interactions/preview.js-generated-config-entry.js ./.storybook/preview.js-generated-config-entry.js ./generated-stories-entry.js
Child HtmlWebpackCompiler:
Asset Size Chunks Chunk Names
__child-HtmlWebpackPlugin_0 6.25 KiB HtmlWebpackPlugin_0 HtmlWebpackPlugin_0
Entrypoint HtmlWebpackPlugin_0 = __child-HtmlWebpackPlugin_0
[./node_modules/html-webpack-plugin/lib/loader.js!./node_modules/#storybook/core-common/templates/index.ejs] 2.04 KiB {HtmlWebpackPlugin_0} [built]
ModuleParseError: Module parse failed: Unexpected character '#' (14:4)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| */
| class Emitter {
> #events;
| #maxListeners;
| #hasWarnedAboutPotentialMemortyLeak;
at handleParseError (/Users/akeikha/Documents/code/pharmacy-management-ui/node_modules/#storybook/builder-webpack4/node_modules/webpack/lib/NormalModule.js:469:19)
at /Users/akeikha/Documents/code/pharmacy-management-ui/node_modules/#storybook/builder-webpack4/node_modules/webpack/lib/NormalModule.js:503:5
at /Users/akeikha/Documents/code/pharmacy-management-ui/node_modules/#storybook/builder-webpack4/node_modules/webpack/lib/NormalModule.js:358:12
at /Users/akeikha/Documents/code/pharmacy-management-ui/node_modules/#storybook/builder-webpack4/node_modules/loader-runner/lib/LoaderRunner.js:373:3
at iterateNormalLoaders (/Users/akeikha/Documents/code/pharmacy-management-ui/node_modules/#storybook/builder-webpack4/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
at Array.<anonymous> (/Users/akeikha/Documents/code/pharmacy-management-ui/node_modules/#storybook/builder-webpack4/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
at Storage.finished (/Users/akeikha/Documents/code/pharmacy-management-ui/node_modules/#storybook/builder-webpack4/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
at /Users/akeikha/Documents/code/pharmacy-management-ui/node_modules/#storybook/builder-webpack4/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
at /Users/akeikha/Documents/code/pharmacy-management-ui/node_modules/graceful-fs/graceful-fs.js:123:16
at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3)
ModuleParseError: Module parse failed: Unexpected token (5:11)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| exports.MemoryLeakError = void 0;
| class MemoryLeakError extends Error {
> emitter;
| type;
| count;
at handleParseError (/Users/akeikha/Documents/code/pharmacy-management-ui/node_modules/#storybook/builder-webpack4/node_modules/webpack/lib/NormalModule.js:469:19)
at /Users/akeikha/Documents/code/pharmacy-management-ui/node_modules/#storybook/builder-webpack4/node_modules/webpack/lib/NormalModule.js:503:5
at /Users/akeikha/Documents/code/pharmacy-management-ui/node_modules/#storybook/builder-webpack4/node_modules/webpack/lib/NormalModule.js:358:12
at /Users/akeikha/Documents/code/pharmacy-management-ui/node_modules/#storybook/builder-webpack4/node_modules/loader-runner/lib/LoaderRunner.js:373:3
at iterateNormalLoaders (/Users/akeikha/Documents/code/pharmacy-management-ui/node_modules/#storybook/builder-webpack4/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
at Array.<anonymous> (/Users/akeikha/Documents/code/pharmacy-management-ui/node_modules/#storybook/builder-webpack4/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
at Storage.finished (/Users/akeikha/Documents/code/pharmacy-management-ui/node_modules/#storybook/builder-webpack4/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
at /Users/akeikha/Documents/code/pharmacy-management-ui/node_modules/#storybook/builder-webpack4/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
at /Users/akeikha/Documents/code/pharmacy-management-ui/node_modules/graceful-fs/graceful-fs.js:123:16
at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3)
WARN Broken build, fix the error above.
WARN You may need to refresh the browser.
info => Loading presets
error Command failed with exit code 1.
I realized from this error that the file Emmiter.js is using es6 syntax and for some reason, my webpack config doesn't have that loader. So I searched for how to override my webpack config without ejecting from here. I also looked for the loader that can interpret es6, and I found this. So I added the code below to my config-override.js
module.exports = function override(config, env) {
config.module.rules[1].oneOf = config.module.rules[1].oneOf
.map((one) => {
if (one.options && one.options.name && one.exclude) {
one.exclude = [/\.(mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/, /\.pdf$/];
}
return one;
})
.concat([
{
test: /\.js$/,
loader: "babel-loader",
options: { presets: ["es2015"] },
},
]);
return config;
};
And updated my scripts on package.json
yarn start gets stuck on Starting the development server...
I'm not even sure if this is the right solution.
Any ideas what the problem is and what I should do here?
Adding these packages to my package.json:
"#storybook/builder-webpack5": "6.5.16",
"#storybook/manager-webpack5": "6.5.16",
"webpack" : "5"
And these lines to my main.ts inside module.export
core: {
builder: "#storybook/builder-webpack5"
},
docs: {
autodocs: true
}
resolved the issue.
My vite react app runs perfectly on Destkop Chrome, but on Mobile it stops working on visit with this error:
RuntimeError: abort(undefined). Build with -s ASSERTIONS=1 for more info.
at n (8ade731a-7b41-4496-bb55-ec8d50e2e255:23:61)
at a (8ade731a-7b41-4496-bb55-ec8d50e2e255:37:394)
at 0011695e:0xf1b
at 0011695e:0x6d8a
at 0011695e:0x4509
at 0011695e:0x3ba9e
at 0011695e:0x27b3e
at 0011695e:0x27cc8
at 0011695e:0x31215
at 0011695e:0x313e7
(anonymous) # 8ade731a-7b41-4496-bb55-ec8d50e2e255:158
Promise.then (async)
onmessage # 8ade731a-7b41-4496-bb55-ec8d50e2e255:142
192.168.1.9/:1 Uncaught (in promise)
{
"type": "error",
"id": 1,
"error": "abort(undefined). Build with -s ASSERTIONS=1 for more info."
}
The warning before the error:
undefined
n # 8ade731a-7b41-4496-bb55-ec8d50e2e255:23
a # 8ade731a-7b41-4496-bb55-ec8d50e2e255:37
$func9 # 0011695e:0xf1b
$func95 # 0011695e:0x6d8a
$func65 # 0011695e:0x4509
$func472 # 0011695e:0x3ba9e
$func272 # 0011695e:0x27b3e
$func274 # 0011695e:0x27cc8
$func394 # 0011695e:0x31215
$func395 # 0011695e:0x313e7
$func227 # 0011695e:0x2226c
$func245 # 0011695e:0x25209
$mb # 0011695e:0x2a94d
a._emscripten_bind_Decoder_DecodeBufferToMesh_2 # 8ade731a-7b41-4496-bb55-ec8d50e2e255:74
h.DecodeBufferToMesh.h.DecodeBufferToMesh # 8ade731a-7b41-4496-bb55-ec8d50e2e255:115
decodeGeometry # 8ade731a-7b41-4496-bb55-ec8d50e2e255:180
(anonymous) # 8ade731a-7b41-4496-bb55-ec8d50e2e255:148
Promise.then (async)
onmessage # 8ade731a-7b41-4496-bb55-ec8d50e2e255:142
So I tried to add -- -s ASSERTATIONS=1 to the dev script:
"scripts": {
"dev": "vite --host -- -s ASSERTIONS=1",
}
Still same error. I have no idea what it could be, since the App is pretty big.
I've been having an issue where one of my Angular 8 apps works without issues and as expected when ran locally (ng serve), however, when built and ran on production (ng build) it will give me the below error when a component is clicked in my app and code is ran.
Error received in console:
ERROR TypeError: Cannot read property 'call' of undefined
at d.l (main-es2015.5d76d03ab70e1112760a.js:1)
at new d (main-es2015.5d76d03ab70e1112760a.js:1)
at Giow.e.exports (main-es2015.5d76d03ab70e1112760a.js:1)
at e.df (main-es2015.5d76d03ab70e1112760a.js:1)
at e.stretch (main-es2015.5d76d03ab70e1112760a.js:1)
at e.getHashPassword (main-es2015.5d76d03ab70e1112760a.js:1)
at p.newAccount (main-es2015.5d76d03ab70e1112760a.js:1)
at Object.handleEvent (main-es2015.5d76d03ab70e1112760a.js:1)
at Object.handleEvent (main-es2015.5d76d03ab70e1112760a.js:1)
at Object.handleEvent (main-es2015.5d76d03ab70e1112760a.js:1)
br # main-es2015.5d76d03ab70e1112760a.js:1
handleError # main-es2015.5d76d03ab70e1112760a.js:1
Xp # main-es2015.5d76d03ab70e1112760a.js:1
(anonymous) # main-es2015.5d76d03ab70e1112760a.js:1
(anonymous) # main-es2015.5d76d03ab70e1112760a.js:1
invokeTask # polyfills-es2015.a8cec314c5933902d1c0.js:1
onInvokeTask # main-es2015.5d76d03ab70e1112760a.js:1
invokeTask # polyfills-es2015.a8cec314c5933902d1c0.js:1
runTask # polyfills-es2015.a8cec314c5933902d1c0.js:1
invokeTask # polyfills-es2015.a8cec314c5933902d1c0.js:1
y # polyfills-es2015.a8cec314c5933902d1c0.js:1
b # polyfills-es2015.a8cec314c5933902d1c0.js:1
Error after disabling minification using below stackblitz example:
ERROR TypeError: Cannot read property 'call' of undefined
at Hmac.CipherBase (main-es2015.02649c002b843ca5ea1e.js:63726)
at new Hmac (main-es2015.02649c002b843ca5ea1e.js:63860)
at createHmac (main-es2015.02649c002b843ca5ea1e.js:63907)
at PasswordService.uno_hkdf (main-es2015.02649c002b843ca5ea1e.js:77684)
at PasswordService.stretch (main-es2015.02649c002b843ca5ea1e.js:77671)
at AppComponent.ngOnInit (main-es2015.02649c002b843ca5ea1e.js:77535)
at checkAndUpdateDirectiveInline (main-es2015.02649c002b843ca5ea1e.js:36518)
at checkAndUpdateNodeInline (main-es2015.02649c002b843ca5ea1e.js:47852)
at checkAndUpdateNode (main-es2015.02649c002b843ca5ea1e.js:47791)
at prodCheckAndUpdateNode (main-es2015.02649c002b843ca5ea1e.js:48645)
Code:
import { Injectable } from '#angular/core';
import { pbkdf2Sync } from 'pbkdf2';
import * as createHmac from 'create-hmac';
#Injectable()
export class PasswordService {
public stretch(emailInput, passwordInput) {
const salt = new Buffer('identity.mozilla.com/picl/v1/' + 'quickStretch' + ':' + emailInput, 'utf8');
const password = new Buffer(passwordInput, 'utf8');
const key: Buffer = pbkdf2Sync(password, salt, 1000, 128, 'sha256');
const info = new Buffer('identity.mozilla.com/picl/v1/' + 'authPW', 'utf8');
const outcome = this.df(key, info, '', 128);
return outcome;
}
df(key, info, salt, length) {
const k = createHmac('sha256', salt).update(key).digest(); /* <----------- FAILS HERE */
const k2 = createHmac('sha256', k);
const counter = new Buffer([1]);
k2.update(info);
k2.update(counter);
return k2.digest().toString('base64');
}
}
After debugging and stepping through the service via developer console, I found that it will fail on the first line of my df function, specifically at createHmac('sha256', salt); It seems like the create-hmac package is undefined, but I'm not sure why it would compile without errors in this case. I have been unable to find any similar issues related to the 'create-hmac' package online which leads me to believe it has something to do with how my app is setup but I'm not sure where to start looking.
Things I have tried from various searches online but always resulted in the same error:
1. rm -rf /node_modules/ -> npm update -> npm install
2. require() instead of import()
3. es5 to es2015 in tsconfig.json
4. Updating create-hmac and pbkdf2 packages
5. Downgrading #angular/cli and #angular-devkit/build-angular
6. Build with other flags such as ```ng build --build-optimizer --aot```
7. Node v10.15, v10.16, and v12.16
8. Using a constructor for createHmac
9. Using import createHmac from 'create-hmac'
ng --version
Angular CLI: 8.3.20
Node: 10.16.0
OS: linux x64
Angular: 8.2.14
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
#angular-devkit/architect 0.803.20
#angular-devkit/build-angular 0.803.20
#angular-devkit/build-optimizer 0.803.20
#angular-devkit/build-webpack 0.803.20
#angular-devkit/core 8.3.20
#angular-devkit/schematics 8.3.20
#angular/cdk 8.2.3
#angular/cli 8.3.20
#angular/http 7.2.16
#angular/material 8.2.3
#ngtools/webpack 8.3.20
#schematics/angular 8.3.20
#schematics/update 0.803.20
rxjs 6.5.4
typescript 3.5.3
webpack 4.39.2
Any insight is appreciated. Thanks!
SOLUTION FOUND
https://forum.aeternity.com/t/important-fix-for-angular-typeerror-cannot-read-property-call-of-undefined-at-hash-cipherbase-index-js-7/4153
Look at this stackblitz I created (with angular 8 as per your setup):
https://stackblitz.com/edit/so-60536842-create-hmac
The one change I had to do to make it work as regards your code is:
import createHmac from 'create-hmac';
Otherwise (import * as createHmac from 'create-hmac';) was throwing me an error: createHmac is not a function
app.js echo script:
Echo:join('chatroom')
.listen('MessagePosted', (e) => {
this.messages.push({
message: e.message.message,
user: e.user
});
});
getting following error:
app.js:37859 [Vue warn]: Error in created hook: "ReferenceError: join
is not defined"
(found in )warn # app.js:37859handleError # app.js:37944callHook
# app.js:39983Vue._init # app.js:41425Vue$3 # app.js:41520(anonymous
function) # app.js:1127__webpack_require__ # app.js:20(anonymous
function) # app.js:47150__webpack_require__ # app.js:20(anonymous
function) # app.js:66(anonymous function) # app.js:69 app.js:37948
ReferenceError: join is not defined(…)handleError #
app.js:37948callHook # app.js:39983Vue._init # app.js:41425Vue$3 #
app.js:41520(anonymous function) # app.js:1127__webpack_require__ #
app.js:20(anonymous function) # app.js:47150__webpack_require__ #
app.js:20(anonymous function) # app.js:66(anonymous function) #
app.js:69 app.js:45006 Download the Vue Devtools extension for a
better development experience:
install pusher and laravel-echo
you can install it by using
npm install --save laravel-echo pusher-js
I hope this helps
you will also need to compile the code
I am working on a Rails 4 project and am trying to write Jasmine tests, but it doesn't look like Jasmine is detecting any of my files.
My spec/javascripts folder looks like this:
./
├── e2e
│ └── products_scenarios.js
├── foo_spec.js
└── support
└── jasmine.yml
and inside jasmine.yml:
# # path to parent directory of src_files
# # relative path from Rails.root
# # defaults to app/assets/javascripts
# src_dir: "app/assets/javascripts"
#
# # path to parent directory of css_files
# # relative path from Rails.root
# # defaults to app/assets/stylesheets
# css_dir: "app/assets/stylesheets"
#
# # list of file expressions to include as source files
# # relative path from src_dir
# src_files:
# - "application.{js.coffee,js,coffee}"
#
# # list of file expressions to include as css files
# # relative path from css_dir
# css_files:
#
# # path to parent directory of spec_files
# # relative path from Rails.root
# # defaults to spec/javascripts
spec_dir: spec/javascripts
#
# # list of file expressions to include as helpers into spec runner
# # relative path from spec_dir
# helpers:
# - "helpers/**/*.{js.coffee,js,coffee}"
# list of file expressions to include as specs into spec runner
# relative path from spec_dir
spec_files:
- "**/*[Ss]pec.{js.coffee,js,coffee}"
# path to directory of temporary files
# (spec runner and asset cache)
# defaults to tmp/jasmine
# tmp_dir: "tmp/jasmine"
and inside foo_spec.js:
describe('Foo', function() {
it("does something", function() {
expect(1+1).toBe(2);
});
});
describe('ProductsCtrl', function() {
beforeEach(module('ilook'));
it('sets title to zzzzz', inject(function($controller) {
var scope = {},
ctrl = $controller('ProductsCtrl', { $scope: scope });
expect(scope.title).toBe("My zzzz");
}));
});
However, when I run the tests:
Nets-Mac-Pro:mysite emai$ be rake spec:javascript
Running `"/Users/emai/.phantomjs/1.9.7/darwin/bin/phantomjs" "/Users/emai/.rvm/gems/ruby-2.0.0-p247#mysite/gems/jasmine-rails-0.9.1/lib/jasmine_rails/../assets/javascripts/jasmine-runner.js" "/Users/emai/Documents/mysite/tmp/jasmine/runner.html?spec="`
Running: /Users/emai/Documents/mysite/tmp/jasmine/runner.html?spec=
Starting...
Finished
-----------------
0 specs, 0 failures in 0.002s.
It says I have no specs. What's going on? I saved all my files.
Add this file
# src_files
#
# Return an array of filepaths relative to src_dir to include before jasmine specs.
# Default: []
#
# EXAMPLE:
#
# src_files:
# - lib/source1.js
# - lib/source2.js
# - dist/**/*.js
#
src_files:
- assets/application.js
- assets/jasmine-jquery.js
# stylesheets
#
# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
# Default: []
#
# EXAMPLE:
#
# stylesheets:
# - css/style.css
# - stylesheets/*.css
#
stylesheets:
- stylesheets/**/*.css
# helpers
#
# Return an array of filepaths relative to spec_dir to include before jasmine specs.
# Default: ["helpers/**/*.js"]
#
# EXAMPLE:
#
# helpers:
# - helpers/**/*.js
#
helpers:
- helpers/**/*.js
# spec_files
#
# Return an array of filepaths relative to spec_dir to include.
# Default: ["**/*[sS]pec.js"]
#
# EXAMPLE:
#
# spec_files:
# - **/*[sS]pec.js
#
spec_files:
- '**/*[sS]pec.js'
# src_dir
#
# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
# Default: project root
#
# EXAMPLE:
#
# src_dir: public
#
src_dir:
# spec_dir
#
# Spec directory path. Your spec_files must be returned relative to this path.
# Default: spec/javascripts
#
# EXAMPLE:
#
# spec_dir: spec/javascripts
#
spec_dir: spec/javascripts
Also try to run below command for running jasmine
rake jasmine
It will give you port number. So run the server on that port numvber