lefthook icon indicating copy to clipboard operation
lefthook copied to clipboard

throws error when running with npx in docker

Open smac89 opened this issue 3 years ago • 1 comments

➜ npx -- @arkweid/lefthook install
internal/modules/cjs/loader.js:905
throw err;
^

Error: Cannot find module '/root/.npm/_npx/459/lib/node_modules/@arkweid/lefthook/postinstall.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @arkweid/[email protected] postinstall: `node postinstall.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @arkweid/[email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-12-28T20_51_18_211Z-debug.log
Install for [ '@arkweid/lefthook@latest' ] failed with code 1

Contents of the log file:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/usr/local/bin/node',
1 verbose cli   '/usr/local/lib/node_modules/npm/bin/npm-cli.js',
1 verbose cli   'install',
1 verbose cli   '@arkweid/lefthook@latest',
1 verbose cli   '--global',
1 verbose cli   '--prefix',
1 verbose cli   '/root/.npm/_npx/459',
1 verbose cli   '--loglevel',
1 verbose cli   'error',
1 verbose cli   '--json'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session e16988047307604d
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 200 https://registry.npmjs.org/@arkweid%2flefthook 19ms (from cache)
8 silly pacote tag manifest for @arkweid/lefthook@latest fetched in 26ms
9 timing stage:loadCurrentTree Completed in 34ms
10 silly install loadIdealTree
11 silly install cloneCurrentTreeToIdealTree
12 timing stage:loadIdealTree:cloneCurrentTree Completed in 0ms
13 silly install loadShrinkwrap
14 timing stage:loadIdealTree:loadShrinkwrap Completed in 1ms
15 silly install loadAllDepsIntoIdealTree
16 silly resolveWithNewModule @arkweid/[email protected] checking installable status
17 timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 3ms
18 timing stage:loadIdealTree Completed in 4ms
19 silly currentTree lib
20 silly idealTree lib
20 silly idealTree `-- @arkweid/[email protected]
21 silly install generateActionsToTake
22 timing stage:generateActionsToTake Completed in 2ms
23 silly diffTrees action count 1
24 silly diffTrees add @arkweid/[email protected]
25 silly decomposeActions action count 8
26 silly decomposeActions fetch @arkweid/[email protected]
27 silly decomposeActions extract @arkweid/[email protected]
28 silly decomposeActions preinstall @arkweid/[email protected]
29 silly decomposeActions build @arkweid/[email protected]
30 silly decomposeActions install @arkweid/[email protected]
31 silly decomposeActions postinstall @arkweid/[email protected]
32 silly decomposeActions finalize @arkweid/[email protected]
33 silly decomposeActions refresh-package-json @arkweid/[email protected]
34 silly install executeActions
35 silly doSerial global-install 8
36 verbose correctMkdir /root/.npm/_locks correctMkdir not in flight; initializing
37 verbose lock using /root/.npm/_locks/staging-42207544aa1d3220.lock for /root/.npm/_npx/459/lib/node_modules/.staging
38 silly doParallel extract 1
39 silly extract @arkweid/[email protected]
40 silly tarball trying @arkweid/lefthook@latest by hash: sha512-Eq30OXKmjxIAIsTtbX2fcF3SNZIXS8yry1u8yty7PQFYRctx04rVlhOJCEB2UmfTh8T2vrOMC9IHHUvvo5zbaQ==
41 silly extract @arkweid/lefthook@latest extracted to /root/.npm/_npx/459/lib/node_modules/.staging/@arkweid/lefthook-ee256751 (244ms)
42 timing action:extract Completed in 247ms
43 silly doReverseSerial unbuild 8
44 silly doSerial remove 8
45 silly doSerial move 8
46 silly doSerial finalize 8
47 silly finalize /root/.npm/_npx/459/lib/node_modules/@arkweid/lefthook
48 timing action:finalize Completed in 2ms
49 silly doParallel refresh-package-json 1
50 silly refresh-package-json /root/.npm/_npx/459/lib/node_modules/@arkweid/lefthook
51 timing action:refresh-package-json Completed in 7ms
52 silly doParallel preinstall 1
53 silly preinstall @arkweid/[email protected]
54 info lifecycle @arkweid/[email protected]~preinstall: @arkweid/[email protected]
55 timing action:preinstall Completed in 1ms
56 silly doSerial build 8
57 silly build @arkweid/[email protected]
58 info linkStuff @arkweid/[email protected]
59 silly linkStuff @arkweid/[email protected] has /root/.npm/_npx/459/lib/node_modules as its parent node_modules
60 silly linkStuff @arkweid/[email protected] is part of a global install
61 silly linkStuff @arkweid/[email protected] is installed into a global node_modules
62 silly linkStuff @arkweid/[email protected] is installed into the top-level global node_modules
63 verbose linkBins [ { lefthook: 'bin/index.js' }, '/root/.npm/_npx/459/bin', true ]
64 silly gently link link does not already exist {
64 silly gently link   link: '/root/.npm/_npx/459/bin/lefthook',
64 silly gently link   target: '/root/.npm/_npx/459/lib/node_modules/@arkweid/lefthook/bin/index.js'
64 silly gently link }
65 timing action:build Completed in 2ms
66 silly doSerial global-link 8
67 silly doParallel update-linked 0
68 silly doSerial install 8
69 silly install @arkweid/[email protected]
70 info lifecycle @arkweid/[email protected]~install: @arkweid/[email protected]
71 timing action:install Completed in 1ms
72 silly doSerial postinstall 8
73 silly postinstall @arkweid/[email protected]
74 info lifecycle @arkweid/[email protected]~postinstall: @arkweid/[email protected]
75 verbose lifecycle @arkweid/[email protected]~postinstall: unsafe-perm in lifecycle false
76 verbose lifecycle @arkweid/[email protected]~postinstall: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/root/.npm/_npx/459/lib/node_modules/@arkweid/lefthook/node_modules/.bin:/root/.npm/_npx/459/lib/node_modules/.bin:/code/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
77 verbose lifecycle @arkweid/[email protected]~postinstall: CWD: /root/.npm/_npx/459/lib/node_modules/@arkweid/lefthook
78 silly lifecycle @arkweid/[email protected]~postinstall: Args: [ '-c', 'node postinstall.js' ]
79 silly lifecycle @arkweid/[email protected]~postinstall: Returned: code: 1  signal: null
80 info lifecycle @arkweid/[email protected]~postinstall: Failed to exec postinstall script
81 timing action:postinstall Completed in 61ms
82 verbose unlock done using /root/.npm/_locks/staging-42207544aa1d3220.lock for /root/.npm/_npx/459/lib/node_modules/.staging
83 timing stage:rollbackFailedOptional Completed in 4ms
84 timing stage:runTopLevelLifecycles Completed in 369ms
85 verbose stack Error: @arkweid/[email protected] postinstall: `node postinstall.js`
85 verbose stack Exit status 1
85 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
85 verbose stack     at EventEmitter.emit (events.js:400:28)
85 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
85 verbose stack     at ChildProcess.emit (events.js:400:28)
85 verbose stack     at maybeClose (internal/child_process.js:1058:16)
85 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
86 verbose pkgid @arkweid/[email protected]
87 verbose cwd /code
88 verbose Linux 5.13.0-22-generic
89 verbose argv "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/bin/npm-cli.js" "install" "@arkweid/lefthook@latest" "--global" "--prefix" "/root/.npm/_npx/459" "--loglevel" "error" "--json"
90 verbose node v14.18.1
91 verbose npm  v6.14.15
92 error code ELIFECYCLE
93 error errno 1
94 error @arkweid/[email protected] postinstall: `node postinstall.js`
94 error Exit status 1
95 error Failed at the @arkweid/[email protected] postinstall script.
95 error This is probably not a problem with npm. There is likely additional logging output above.
96 verbose exit [ 1, true ]

This looks very similar to this other issue https://github.com/vercel/vercel/issues/2425. Maybe there is something that needs to be done when installing inside a docker container?

smac89 avatar Dec 28 '21 20:12 smac89

The only way I've found to make this work is to use the following inside the container

yarn global add @arkweid/lefthook

smac89 avatar Dec 29 '21 01:12 smac89

I guess this is already fixed with the new lefthook npm package.

mrexox avatar Nov 14 '22 08:11 mrexox