Here’s how I would approach this. I would take a look in your project’s Trellis code for the Run npm install
task that failed, to understand what it is doing. You’re probably using this version of the build-before.yml
file.
- name: Run npm install
command: npm install
connection: local
args:
chdir: "{{ project.local_path }}/web/app/themes/sage"
It cd
s (chdir
) into your local machine’s theme directory in your local_path
and runs the specified command: npm install
. The connection: local
means that this command will be run on the local machine, not the server.
Now that we understand what is happening, we can try a common troubleshooting technique: “manually run the command where Ansible failed.” Try running npm install
on your local machine in your theme directory. You’ll probably see the same warning messages, but hopefully this will give even more info and you’ll get to troubleshoot with Ansible out of the picture.
This appears to be just an issue of npm install
on your local machine, not really an issue with Trellis code. Trellis assumes you’ve worked out successful theme asset build on your local machine. The build-before.yml
file is just an example of how you can create your own tasks to build your theme assets, if desired.
You may want to see these classic NPM Dubugging Guidelines. For example, it mentions “Do not use sudo with npm.” If you use sudo with npm, it could cause all sorts of troubles, but also note that the Trellis command above isn’t using sudo with npm install
. If somehow you must use sudo, you may need to add sudo to the command
, or add become: true
to the task.
If you can’t get the manual npm install
to work at all, you could comment out the associated task (and maybe the bower task) in build-before.yml
and just leave the gulp and sync tasks. That might help you get a successful deploy for the short term, but of course you’ll want to sort out your npm issues in the long term. If none of those tasks work. in a pinch you could just comment them out and sync up your built theme assets manually using rsync.