Reggionick / s3-deploy

Easily deploy a static website to AWS S3 and invalidate CloudFront distribution
MIT License
238 stars 83 forks source link

npx NOENT error #24

Open Tarang opened 3 years ago

Tarang commented 3 years ago

I keep getting this error

Error: There was an error when attempting to execute the process '/opt/hostedtoolcache/node/12.20.0/x64/bin/npx'. This may indicate the process failed to start. Error: spawn /opt/hostedtoolcache/node/12.20.0/x64/bin/npx ENOENT

I'm a bit unsure what is causing it. I have copied and pasted the yaml on the README pretty much verbatim and used my credentials. I can see there is a related closed issue https://github.com/Reggionick/s3-deploy/issues/13 but it was not resolved.

themakshter commented 3 years ago

I am also facing this - any ideas why?

themakshter commented 3 years ago

I have fixed my issue.

@Tarang, perhaps the directory that you are trying to upload isn't present. Could you provide with details of your action?

Tarang commented 3 years ago

Pretty sure the directory is there, if i use s3 deploy directly it works fine

Reggionick commented 3 years ago

Hi @Tarang, do you still have this issue? Cloud you paste your action workflow?

Tarang commented 3 years ago

Pretty much the example and just changing the folder to dist:

name: Example workflow for S3 Deploy
on: [push]
jobs:
  run:
    runs-on: ubuntu-latest
    env:
      AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
    steps:
        - uses: actions/checkout@v2

        - name: Deploy
          uses: reggionick/s3-deploy@v3
          with:
            folder: dist
            bucket: ${{ secrets.S3_BUCKET }}
            bucket-region: ${{ secrets.S3_BUCKET_REGION }}
            dist-id: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}
            invalidation: /
            delete-removed: true
            no-cache: true
            private: true

Instead I am doing this to fix it

      - uses: jakejarvis/s3-sync-action@master
        with:
          args: --acl public-read --follow-symlinks --delete
        env:
          AWS_S3_BUCKET: ${{ secrets.S3_BUCKET }}
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          AWS_REGION: ${{ secrets.S3_BUCKET_REGION }}
          SOURCE_DIR: 'dist'

      # Invalidate Cloudfront (this action)
      - name: invalidate
        uses: chetan/invalidate-cloudfront-action@master
        env:
          DISTRIBUTION: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}
          PATHS: '/*'
          AWS_REGION: ${{ secrets.S3_BUCKET_REGION }}
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Reggionick commented 3 years ago

Pretty much the example and just changing the folder to dist:

Don't you compile anything? Is the folder dist into your repo?

Tarang commented 3 years ago

I compile it in the previous step I erased. But keep in mind the code i replace (in the previous post) works fine and it uses the dist folder.

I also did try alot of debugging to see what was going on, i.e i added bash scripts to ls and see if anything was there and I could 100% see the dist folder. Also the npx binary it says NOENT to actually exists so I would guess its some kind of other issue where something has changed and this package hasnt been updated

yankeeinlondon commented 3 years ago
image

@Reggionick i have a Vuepress site which gets built using node (this works successfully) but then I get this error. I am trying to use your action to deploy to an S3 AccessPoint so I might indeed have some permission issues there but it would appear it's falling over before we get to that point.

Reggionick commented 3 years ago

I've encountered this issue in a new project. I found out that the issue was due to a wrong path: In the action I've set a working directory like:

    defaults:
      run:
        working-directory: frontend

but it seems that the npx command is executed from the repo root path. I think this because changing the action folder param into ./frontend/build it works.

I haven't check in detail this, but is this scenario like yours?

yankeeinlondon commented 3 years ago

@Reggionick in your example what does "frontend" represent? Is that where the build assets are being built to? I have been setting the SOURCE_DIR ENV variable to point to the correct pickup point for S3 content and assuming that the path should be relative to the root of the repo.

Having come back to this issue after a week or so I'm not sure if it's moved forward or backward but for me I no longer get the error regarding the execution of npx but instead get the error: fatal error: An error occurred (NoSuchKey) when calling the ListObjectsV2 operation: The specified key does not exist.

image

So to be explicit, I setup an Identity step in my action which follows the build of the static assets and precedes me using your repo to push this to an S3 bucket. From this I have validated that indeed npx is in the path at /opt/hostedtoolcache/node/14.16.1/x64/bin/npx and I guess my current working directory is /home/runner/work/***/*** where I'm assuming the **** are obfuscating what might be deemed "secret info".

The error message refers to ListObjectsV2 which I am a little uncertain of where this originates but URL structure for an S3 AccessPoint is something like this:

image

and thereby different from access patterns that point directly to the S3 bucket itself. Not sure if this could be causing the issue but I am able to access the bucket via the Access Point using Panic's Transmit application so the permissions to interact with the bucket are setup correctly. And now, to my great surprise, I can see that in fact this repo's code DID move the files over to the repo:

image

and the error must have been thrown after the operation had succeeded.

yankeeinlondon commented 3 years ago

Ok, i'm now even more confused ... I had had set the AWS_REGION in my action by referring to ${{ secrets.AWS_REGION }} but since this isn't really a "secret" I just plain texted it and while I wasn't expecting that to make any difference (as I'd double checked that the secret was indeed set on github) ... it appears to have made it work!

I guess this must mean I had fat fingered the AWS_REGION secret in github ... not sure what else would explain it. Anyway, sorry for the red herring.

flodev commented 2 years ago

I've encountered this issue in a new project. I found out that the issue was due to a wrong path: In the action I've set a working directory like:

    defaults:
      run:
        working-directory: frontend

but it seems that the npx command is executed from the repo root path. I think this because changing the action folder param into ./frontend/build it works.

I haven't check in detail this, but is this scenario like yours?

Hi, thanks for giving this hint. I can confirm that it works. I have the same setup: Monorepo and a frontend folder that contains the build folder and I had the same issue with EOENT. Changing s3-deploy to folder: ./frontend/buildworked for me. Regards Florian

AJSihota commented 1 year ago

I'm experiencing the same issue. I tried to change the folder but even in the correct path where the build asssets are, I get the npx error