Zend certified PHP/Magento developer

Custom javascript not running from module

I have a Magento module that currently provides a custom API route. I am wanting to update it to push some Javascript to the /customer/account page.

I tried following the answer here but this didn’t work, my script is not rendered or executed on the customer account page.

My module looks like this:

module directory

My module lives in app/Code/James/AddToCart.

I have a app/code/James/AddToCart/view/frontend/layout/customer_account_index.xml file that looks like this:

< ?xml version="1.0"?>

    
    
    

I then have the Javascript file living in app/code/James/AddToCart/view/frontend/web/js/postMessage.js and it looks like this:

console.log('test');
alert('I am working');

The real script I will use is not the above, however it is all just vanilla javascript with no dependencies.

I then ran these commands (not sure if necessary):

php bin/magento maintenance:enable
php bin/magento setup:upgrade
php -d memory_limit=2G bin/magento setup:di:compile
history
php -d memory_limit=8G -d max_execution_time=18000 bin/magento setup:static-content:deploy -f
php bin/magento maintenance:disable
php bin/magento cache:clean
php bin/magento cache:flush
redis-cli -p 6379 flushall

However when I go to the /customer/account page, I do not see my script run at all.

What am I doing wrong?