Try the following code in a script - works for me on Tmux 3.1:
#!/bin/bash
Create a new session named "newsess", split panes and change directory in each
tmux new-session -d -s newsess
tmux send-keys -t newsess "cd /path/to/directory1" Enter
tmux split-window -h -t newsess
tmux send-keys -t newsess "cd /path/to/directory2" Enter
tmux split-window -v -p 66 -t newsess
tmux send-keys -t newsess "cd /path/to/directory3" Enter
tmux split-window -v -t newsess
tmux send-keys -t newsess "cd /path/to/directory4" Enter
tmux split-window -v -t newsess
tmux send-keys -t newsess "cd /path/to/directory5" Enter
tmux select-pane -t newsess:0.0
tmux split-window -v -p 66 -t newsess
tmux send-keys -t newsess "cd /path/to/directory6" Enter
tmux split-window -v -p 66 -t newsess
tmux send-keys -t newsess "cd /path/to/directory7" Enter
tmux split-window -v -t newsess
tmux send-keys -t newsess "cd /path/to/directory8" Enter
Set pane synchronization
tmux set-window-option -t newsess:0 synchronize-panes on
Run command in all 8 panes
tmux send-keys -t newsess "npm run dev" Enter
Attach to session named "newsess"
tmux attach -t newsess
For testing I'd recommend running pwd
instead of whatever command you wish to run in 8 panes simultaneously (also to check directories are correct). ;-)
If you want to run different commands in each pane, you of course just run the command with send-keys
after changing directory. But I was under the impression that you want to run the same command in each pane, and that's why pane synchronization would work.