Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 5952

getting an "Error: ENOENT: no such file or directory, scandir " in nodejs

$
0
0

I'm trying to clone a nodejs project from github in a docker container, run and build it so i can upload build files to my amazon s3 bucket

executing npm run build creates a dist folder and i'm trying to get all the files inside it but not able to...

running npm rebuild node-sass would solve the problem if saas is enabled but that's not the case here

here is my Dockerfile

FROM ubuntu:focalRUN apt-get updateRUN apt-get install -y curlRUN curl -sL https://deb.nodesource.com/setup_20.x | bash -RUN apt-get upgrade -yRUN apt-get install -y nodejsRUN apt-get install git -yWORKDIR /home/appCOPY main.sh main.shCOPY script.js script.jsCOPY package*.json .RUN npm install# chmod +x --> gives permission to make main.sh and script.js executableRUN chmod +x main.shRUN chmod +x script.jsENTRYPOINT [ "/home/app/main.sh" ]

main.sh

#!/bin/bashexport GIT_REPOSITORY_URL="$GIT_REPOSITORY_URL"git clone "$GIT_REPOSITORY_URL" /home/app/ouputexec node script.js

script.js

const {exec} = require("child_process");const path = require("path");const fs = require("fs");const s3Client = new S3Client({    region: '',    credentials : {        accessKeyId: '',        secretAccessKey: ''    }})async function fun(){    console.log("Executing script.js");    const outDirPath = path.join(__dirname, 'output')    const process = exec(`cd ${outDirPath} && npm install && npm run build && ls`);    process.stdout.on('data', function(data) {        console.log(data.toString());    })    process.stderr.on('error', function(data) {        console.log('Error', data.toString());    })    process.on('close', async function(){        console.log('Build Complete');        const distFolderPath = path.join(__dirname, 'output', 'dist');        const distFolderContents = fs.readdirSync(distFolderPath, {recursive: true});        //...rest of the code    })}fun();

it clones, runs and builds successfully but cant find the dist folder


Viewing all articles
Browse latest Browse all 5952

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>