sambaiz / puppeteer-lambda-starter-kit

Starter Kit for running Headless-Chrome by Puppeteer on AWS Lambda.
MIT License
580 stars 82 forks source link

Cannot cd into '/tmp' #4

Open md97212 opened 6 years ago

md97212 commented 6 years ago

In trying to setup local chome in this block,

const setupLocalChrome = () => {
    return new Promise((resolve, reject) => {
        fs.createReadStream(config.localChromePath)
            .on('error', (err) => reject(err))
            .pipe(tar.x({
                C: config.setupChromePath,
            }))
            .on('error', (err) => reject(err))
            .on('end', () => resolve());
    });
};

I get this error, has anyone else bumped into this and found a good solution? I suppose I can chmod the /tmp directory but that seems like a hack.

Cwd Error ----------------------------------------------

  ENOTDIR: Cannot cd into '/tmp'

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Stack Trace --------------------------------------------

CwdError: ENOTDIR: Cannot cd into '/tmp'
    at CwdError (/Users/mark/dev/repos/spr-renderer/node_modules/tar/lib/mkdir.js:26:5)
    at fs.lstat (/Users/mark/dev/repos/spr-renderer/node_modules/tar/lib/mkdir.js:74:14)
    at FSReqWrap.oncomplete (fs.js:123:15)
ThePaulMcBride commented 6 years ago

I'm running into the same problem trying to run this locally. Did you find a solution?

MikeGertrudes commented 6 years ago

I switched the code from:

.pipe(tar.x({
  C: path.join(path.sep, 'tmp')
}))

to:

.pipe(tar.x({
  C: path.join(process.cwd(), path.sep, 'tmp')
}))

and it worked (after creating tmp directory in my application folder).

conanmy commented 6 years ago

@MikeGertrudes I have got this worked in Lambda, for lambda usage, seems you shouldn't add that "process.cwd()".