decktape icon indicating copy to clipboard operation
decktape copied to clipboard

Dependencies are not hoisted

Open nicojs opened this issue 2 years ago • 3 comments

I've noticed that the dependencies of decktape are never hoisted.

For example:

mkdir tmp && cd tmp
npm i --save-exact [email protected]
tree node_modules/ -L 3
node_modules/
└── decktape
    ├── node_modules
    │   ├── puppeteer
    │   ├── puppeteer-core
    [...]
    │   └── ylru
    ├── npm-shrinkwrap.json
    ├── package.json
    └── plugins

This is a problem when you later install a version of puppeteer yourself, it gets duplicated in your node_modules:

npm i --save-exact [email protected]
tree node_modules/ -L 3
node_modules/
└── decktape
    ├── node_modules
    │   ├── puppeteer # 👈 here
    │   ├── puppeteer-core
    [...]
    ├── package.json
    └── plugins
├── puppeteer # 👈 and here
├── puppeteer-core  
[...]

... which is a problem, because installing 2 versions of puppeteer simultaneously doesn't seem to work:

npm WARN cleanup Failed to remove some directories [
npm WARN cleanup   [
npm WARN cleanup     'D:\\a\\1\\s\\node_modules\\decktape\\node_modules\\puppeteer',
npm WARN cleanup     [Error: EBUSY: resource busy or locked, rmdir 'D:\a\1\s\node_modules\decktape\node_modules\puppeteer'] {
npm WARN cleanup       errno: -4082,
npm WARN cleanup       code: 'EBUSY',
npm WARN cleanup       syscall: 'rmdir',
npm WARN cleanup       path: 'D:\\a\\1\\s\\node_modules\\decktape\\node_modules\\puppeteer'
npm WARN cleanup     }
npm WARN cleanup   ],
npm WARN cleanup   [
npm WARN cleanup     'D:\\a\\1\\s\\node_modules\\decktape\\node_modules',
npm WARN cleanup     [Error: EBUSY: resource busy or locked, rmdir 'D:\a\1\s\node_modules\decktape\node_modules\puppeteer'] {
npm WARN cleanup       errno: -4082,
npm WARN cleanup       code: 'EBUSY',
npm WARN cleanup       syscall: 'rmdir',
npm WARN cleanup       path: 'D:\\a\\1\\s\\node_modules\\decktape\\node_modules\\puppeteer'
npm WARN cleanup     }
npm WARN cleanup   ],
npm WARN cleanup   [
npm WARN cleanup     'D:\\a\\1\\s\\node_modules\\decktape',
npm WARN cleanup     [Error: EBUSY: resource busy or locked, rmdir 'D:\a\1\s\node_modules\decktape\node_modules\puppeteer'] {
npm WARN cleanup       errno: -4082,
npm WARN cleanup       code: 'EBUSY',
npm WARN cleanup       syscall: 'rmdir',
npm WARN cleanup       path: 'D:\\a\\1\\s\\node_modules\\decktape\\node_modules\\puppeteer'
npm WARN cleanup     }
npm WARN cleanup   ],
npm WARN cleanup   [
npm WARN cleanup     'D:\\a\\1\\s\\node_modules',
npm WARN cleanup     [Error: EBUSY: resource busy or locked, rmdir 'D:\a\1\s\node_modules\decktape\node_modules\puppeteer'] {
npm WARN cleanup   ]
npm WARN cleanup ]
npm ERR! code 1
npm ERR! path D:\a\1\s\node_modules\puppeteer

I'm reasonably sure this hoisting behavior is caused by the npm-shrinkwrap.json file. Is this file there by choice? Or can we change it to a package-lock.json file?

nicojs avatar Apr 04 '23 17:04 nicojs

Hi @nicojs, I remember some issues with npm install and package-lock.json, which led to changing to using npm-shrinkwrap.json: https://github.com/astefanutti/decktape/issues/136#issuecomment-392725841.

We can certainly re-assess what's the best option.

astefanutti avatar Apr 05 '23 14:04 astefanutti

@astefanutti what is the process of installing decktape properly? I don't think decktape installs puppeteer.... Do we have to manually install puppeteer globally?

Error: Could not find Chrome (ver. 115.0.5790.98). This can occur if either
 1. you did not perform an installation before running the script (e.g. `npm install`) or
 2. your cache path is incorrectly configured (which is: /home/ubuntu/.cache/puppeteer).
For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.
    at ChromeLauncher.resolveExecutablePath (file:///usr/lib/node_modules/decktape/node_modules/puppeteer-core/lib/esm/puppeteer/node/ProductLauncher.js:274:27)
    at ChromeLauncher.executablePath (file:///usr/lib/node_modules/decktape/node_modules/puppeteer-core/lib/esm/puppeteer/node/ChromeLauncher.js:174:25)
    at ChromeLauncher.computeLaunchArguments (file:///usr/lib/node_modules/decktape/node_modules/puppeteer-core/lib/esm/puppeteer/node/ChromeLauncher.js:91:37)
    at async ChromeLauncher.launch (file:///usr/lib/node_modules/decktape/node_modules/puppeteer-core/lib/esm/puppeteer/node/ProductLauncher.js:53:28)
    at async file:///usr/lib/node_modules/decktape/decktape.js:254:19

0xDevrim avatar Aug 30 '23 13:08 0xDevrim

@0xDevrim Chrome is supposed to be installed by Puppeteer when Decktape is installed, e.g., with npm install -g decktape. The Puppeteer runs a post-install script that downloads Chrome and installs it in the cache.

What's the output when you run npm install -g decktape?

astefanutti avatar Sep 28 '23 10:09 astefanutti

@0xDevrim Chrome is supposed to be installed by Puppeteer when Decktape is installed, e.g., with npm install -g decktape. The Puppeteer runs a post-install script that downloads Chrome and installs it in the cache.

What's the output when you run npm install -g decktape?

I don't manage the server myself but I just asked the host to update decktape and send me the output. I will edit this reply with the output if I still have the same issue.

@astefanutti got the same issue again.

Error: Could not find Chrome (ver. 126.0.6478.126). This can occur if either
 1. you did not perform an installation before running the script (e.g. `npx puppeteer browsers install chrome`) or
 2. your cache path is incorrectly configured (which is: /home/prod_thumbnail/.cache/puppeteer).
For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.
    at ChromeLauncher.resolveExecutablePath (file:///usr/lib/node_modules/decktape/node_modules/puppeteer-core/lib/esm/puppeteer/node/ProductLauncher.js:269:27)
    at ChromeLauncher.executablePath (file:///usr/lib/node_modules/decktape/node_modules/puppeteer-core/lib/esm/puppeteer/node/ChromeLauncher.js:203:25)
    at ChromeLauncher.computeLaunchArguments (file:///usr/lib/node_modules/decktape/node_modules/puppeteer-core/lib/esm/puppeteer/node/ChromeLauncher.js:83:37)
    at async ChromeLauncher.launch (file:///usr/lib/node_modules/decktape/node_modules/puppeteer-core/lib/esm/puppeteer/node/ProductLauncher.js:44:28)
    at async file:///usr/lib/node_modules/decktape/decktape.js:254:19

Log:

root@prod-wkr-a:~# npm install -g decktape
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '[email protected]',
npm WARN EBADENGINE   required: { node: '>=18' },
npm WARN EBADENGINE   current: { node: 'v16.20.2', npm: '8.19.4' }
npm WARN EBADENGINE }

added 21 packages, removed 9 packages, changed 113 packages, and audited
135 packages in 2s

11 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
root@prod-wkr-a:~# decktape version
3.13.0

sadikyalcin avatar Aug 01 '24 11:08 sadikyalcin