Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"node: command not found" when using nvm and sudo/root #2633

Closed
Markshall opened this issue Mar 22, 2021 · 2 comments
Closed

"node: command not found" when using nvm and sudo/root #2633

Markshall opened this issue Mar 22, 2021 · 2 comments

Comments

@Markshall
Copy link

I'm running an npm install script inside a directory that I've cloned from git, one of the dependancies is Sharp, but when I run npm install, it tells me that node and node-gyp commands don't exist and yells at me about an install script that Sharp tries to execute:
(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

My computer is running node 14.15.0 and npm 7.5.2 and it works fine there.
When I try on an Amazon Linux 2 EC2 instance to serve this app on the internet, running node 14.15.0 and npm 6.14.8 (through nvm), I get this crashing error.


Did you see the documentation relating to installation?
Yes

Have you ensured the architecture and platform of Node.js used for npm install is the same as the architecture and platform of Node.js used at runtime?
Yes (I think?). Using node 14.15.0 (npm 6.14.8) via nvm

Are you using the latest version? Is the version currently in use as reported by npm ls sharp the same as the latest version as reported by npm view sharp dist-tags.latest?
Yes (0.27.2)

If you are using npm v6 or earlier and installing as a root or sudo user, have you tried with the npm install --unsafe-perm flag?
Yes, I get the same error

If you are using npm v7, does the user running npm install own the directory it is run in?
N/A

If you are using the ignore-scripts feature of npm, have you tried with the npm install --ignore-scripts=false flag?
I don't use ignore-scripts, but I tried the flag regardless and got the same error.

What is the complete output of running npm install --verbose sharp? Have you checked this output for useful error messages?

npm info it worked if it ends with ok
npm verb cli [
npm verb cli   '/root/.nvm/versions/node/v14.15.0/bin/node',
npm verb cli   '/root/.nvm/versions/node/v14.15.0/bin/npm',
npm verb cli   'install',
npm verb cli   '--verbose',
npm verb cli   'sharp'
npm verb cli ]
npm info using npm@6.14.8
npm info using node@v14.15.0
npm verb npm-session 2f088e26edfac318
npm http fetch GET 304 https://registry.npmjs.org/sharp 99ms (from cache)
npm timing stage:loadCurrentTree Completed in 154ms
npm timing stage:loadIdealTree:cloneCurrentTree Completed in 0ms
npm timing stage:loadIdealTree:loadShrinkwrap Completed in 3ms
npm http fetch GET 304 https://registry.npmjs.org/array-flatten 66ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/npmlog 96ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/tar-fs 116ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/simple-get 119ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/tunnel-agent 117ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/detect-libc 132ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/semver 132ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/prebuild-install 140ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/color 148ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/node-addon-api 155ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/color-string 27ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/color-convert 76ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/color-name 42ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/simple-swizzle 28ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/is-arrayish 33ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/console-control-strings 45ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/set-blocking 45ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/are-we-there-yet 47ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/gauge 83ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/delegates 46ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/readable-stream 59ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/inherits 53ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/isarray 57ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/process-nextick-args 67ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/safe-buffer 68ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/core-util-is 70ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/string_decoder 72ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/util-deprecate 73ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/object-assign 11ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/aproba 47ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/signal-exit 56ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/wide-align 57ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/strip-ansi 58ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/string-width 66ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/has-unicode 69ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/code-point-at 33ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/is-fullwidth-code-point 65ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/number-is-nan 34ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/ansi-regex 32ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/expand-template 64ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/pump 70ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/napi-build-utils 94ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/minimist 96ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/github-from-package 103ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/mkdirp-classic 102ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/rc 101ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/node-abi 105ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/which-pm-runs 89ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/noop-logger 107ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/once 27ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/end-of-stream 38ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/wrappy 31ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/deep-extend 23ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/strip-json-comments 31ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/ini 40ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/simple-concat 43ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/decompress-response 81ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/mimic-response 40ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/tar-stream 32ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/chownr 49ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/bl 31ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/fs-constants 116ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/buffer 33ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/base64-js 33ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/ieee754 39ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/lru-cache 37ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/yallist 25ms (from cache)
npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 1524ms
npm timing stage:loadIdealTree Completed in 1555ms
npm timing stage:generateActionsToTake Completed in 18ms
npm verb correctMkdir /root/.npm/_locks correctMkdir not in flight; initializing
npm verb lock using /root/.npm/_locks/staging-dff8604cf3b8aea3.lock for /var/www/html/node_modules/.staging
npm timing audit submit Completed in 288ms
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/audits/quick 288ms
npm timing audit body Completed in 3ms
npm timing action:extract Completed in 348ms
npm timing action:finalize Completed in 73ms
npm timing action:refresh-package-json Completed in 189ms
npm info lifecycle ansi-regex@2.1.1~preinstall: ansi-regex@2.1.1
npm info lifecycle aproba@1.2.0~preinstall: aproba@1.2.0
npm info lifecycle base64-js@1.5.1~preinstall: base64-js@1.5.1
npm info lifecycle chownr@1.1.4~preinstall: chownr@1.1.4
npm info lifecycle code-point-at@1.1.0~preinstall: code-point-at@1.1.0
npm info lifecycle color-name@1.1.3~preinstall: color-name@1.1.3
npm info lifecycle color-convert@1.9.3~preinstall: color-convert@1.9.3
npm info lifecycle console-control-strings@1.1.0~preinstall: console-control-strings@1.1.0
npm info lifecycle core-util-is@1.0.2~preinstall: core-util-is@1.0.2
npm info lifecycle deep-extend@0.6.0~preinstall: deep-extend@0.6.0
npm info lifecycle delegates@1.0.0~preinstall: delegates@1.0.0
npm info lifecycle detect-libc@1.0.3~preinstall: detect-libc@1.0.3
npm info lifecycle expand-template@2.0.3~preinstall: expand-template@2.0.3
npm info lifecycle fs-constants@1.0.0~preinstall: fs-constants@1.0.0
npm info lifecycle github-from-package@0.0.0~preinstall: github-from-package@0.0.0
npm info lifecycle has-unicode@2.0.1~preinstall: has-unicode@2.0.1
npm info lifecycle ieee754@1.2.1~preinstall: ieee754@1.2.1
npm info lifecycle buffer@5.7.1~preinstall: buffer@5.7.1
npm info lifecycle inherits@2.0.4~preinstall: inherits@2.0.4
npm info lifecycle ini@1.3.8~preinstall: ini@1.3.8
npm info lifecycle is-arrayish@0.3.2~preinstall: is-arrayish@0.3.2
npm info lifecycle isarray@1.0.0~preinstall: isarray@1.0.0
npm info lifecycle mimic-response@2.1.0~preinstall: mimic-response@2.1.0
npm info lifecycle decompress-response@4.2.1~preinstall: decompress-response@4.2.1
npm info lifecycle minimist@1.2.5~preinstall: minimist@1.2.5
npm info lifecycle mkdirp-classic@0.5.3~preinstall: mkdirp-classic@0.5.3
npm info lifecycle napi-build-utils@1.0.2~preinstall: napi-build-utils@1.0.2
npm info lifecycle semver@5.7.1~preinstall: semver@5.7.1
npm info lifecycle node-abi@2.21.0~preinstall: node-abi@2.21.0
npm info lifecycle noop-logger@0.1.1~preinstall: noop-logger@0.1.1
npm info lifecycle number-is-nan@1.0.1~preinstall: number-is-nan@1.0.1
npm info lifecycle is-fullwidth-code-point@1.0.0~preinstall: is-fullwidth-code-point@1.0.0
npm info lifecycle object-assign@4.1.1~preinstall: object-assign@4.1.1
npm info lifecycle process-nextick-args@2.0.1~preinstall: process-nextick-args@2.0.1
npm info lifecycle safe-buffer@5.1.2~preinstall: safe-buffer@5.1.2
npm info lifecycle set-blocking@2.0.0~preinstall: set-blocking@2.0.0
npm info lifecycle signal-exit@3.0.3~preinstall: signal-exit@3.0.3
npm info lifecycle simple-concat@1.0.1~preinstall: simple-concat@1.0.1
npm info lifecycle mimic-response@3.1.0~preinstall: mimic-response@3.1.0
npm info lifecycle decompress-response@6.0.0~preinstall: decompress-response@6.0.0
npm info lifecycle simple-swizzle@0.2.2~preinstall: simple-swizzle@0.2.2
npm info lifecycle color-string@1.5.5~preinstall: color-string@1.5.5
npm info lifecycle string_decoder@1.1.1~preinstall: string_decoder@1.1.1
npm info lifecycle strip-ansi@3.0.1~preinstall: strip-ansi@3.0.1
npm info lifecycle string-width@1.0.2~preinstall: string-width@1.0.2
npm info lifecycle strip-json-comments@2.0.1~preinstall: strip-json-comments@2.0.1
npm info lifecycle rc@1.2.8~preinstall: rc@1.2.8
npm info lifecycle tunnel-agent@0.6.0~preinstall: tunnel-agent@0.6.0
npm info lifecycle util-deprecate@1.0.2~preinstall: util-deprecate@1.0.2
npm info lifecycle readable-stream@3.6.0~preinstall: readable-stream@3.6.0
npm info lifecycle sharp@0.27.2~preinstall: sharp@0.27.2
npm info lifecycle simple-get@4.0.0~preinstall: simple-get@4.0.0
npm info lifecycle semver@7.3.4~preinstall: semver@7.3.4
npm info lifecycle prebuild-install@6.0.1~preinstall: prebuild-install@6.0.1
npm info lifecycle node-addon-api@3.1.0~preinstall: node-addon-api@3.1.0
npm info lifecycle color@3.1.3~preinstall: color@3.1.3
npm info lifecycle array-flatten@3.0.0~preinstall: array-flatten@3.0.0
npm info lifecycle lru-cache@6.0.0~preinstall: lru-cache@6.0.0
npm info lifecycle yallist@4.0.0~preinstall: yallist@4.0.0
npm info lifecycle tar-fs@2.1.1~preinstall: tar-fs@2.1.1
npm info lifecycle pump@3.0.0~preinstall: pump@3.0.0
npm info lifecycle simple-get@3.1.0~preinstall: simple-get@3.1.0
npm info lifecycle tar-stream@2.2.0~preinstall: tar-stream@2.2.0
npm info lifecycle end-of-stream@1.4.4~preinstall: end-of-stream@1.4.4
npm info lifecycle once@1.4.0~preinstall: once@1.4.0
npm info lifecycle wrappy@1.0.2~preinstall: wrappy@1.0.2
npm info lifecycle npmlog@4.1.2~preinstall: npmlog@4.1.2
npm info lifecycle gauge@2.7.4~preinstall: gauge@2.7.4
npm info lifecycle wide-align@1.1.3~preinstall: wide-align@1.1.3
npm info lifecycle which-pm-runs@1.0.0~preinstall: which-pm-runs@1.0.0
npm info lifecycle readable-stream@3.6.0~preinstall: readable-stream@3.6.0
npm info lifecycle are-we-there-yet@1.1.5~preinstall: are-we-there-yet@1.1.5
npm info lifecycle readable-stream@2.3.7~preinstall: readable-stream@2.3.7
npm info lifecycle bl@4.1.0~preinstall: bl@4.1.0
npm timing action:preinstall Completed in 32ms
npm info linkStuff ansi-regex@2.1.1
npm info linkStuff aproba@1.2.0
npm info linkStuff base64-js@1.5.1
npm info linkStuff chownr@1.1.4
npm info linkStuff code-point-at@1.1.0
npm info linkStuff color-name@1.1.3
npm info linkStuff color-convert@1.9.3
npm info linkStuff console-control-strings@1.1.0
npm info linkStuff core-util-is@1.0.2
npm info linkStuff deep-extend@0.6.0
npm info linkStuff delegates@1.0.0
npm info linkStuff detect-libc@1.0.3
npm verb linkBins [
npm verb linkBins   { 'detect-libc': 'bin/detect-libc.js' },
npm verb linkBins   '/var/www/html/node_modules/.bin',
npm verb linkBins   false
npm verb linkBins ]
npm info linkStuff expand-template@2.0.3
npm info linkStuff fs-constants@1.0.0
npm info linkStuff github-from-package@0.0.0
npm info linkStuff has-unicode@2.0.1
npm info linkStuff ieee754@1.2.1
npm info linkStuff buffer@5.7.1
npm info linkStuff inherits@2.0.4
npm info linkStuff ini@1.3.8
npm info linkStuff is-arrayish@0.3.2
npm info linkStuff isarray@1.0.0
npm info linkStuff mimic-response@2.1.0
npm info linkStuff decompress-response@4.2.1
npm info linkStuff minimist@1.2.5
npm info linkStuff mkdirp-classic@0.5.3
npm info linkStuff napi-build-utils@1.0.2
npm info linkStuff semver@5.7.1
npm verb linkBins [
npm verb linkBins   { semver: 'bin/semver' },
npm verb linkBins   '/var/www/html/node_modules/node-abi/node_modules/.bin',
npm verb linkBins   false
npm verb linkBins ]
npm info linkStuff node-abi@2.21.0
npm info linkStuff noop-logger@0.1.1
npm info linkStuff number-is-nan@1.0.1
npm info linkStuff is-fullwidth-code-point@1.0.0
npm info linkStuff object-assign@4.1.1
npm info linkStuff process-nextick-args@2.0.1
npm info linkStuff safe-buffer@5.1.2
npm info linkStuff set-blocking@2.0.0
npm info linkStuff signal-exit@3.0.3
npm info linkStuff simple-concat@1.0.1
npm info linkStuff mimic-response@3.1.0
npm info linkStuff decompress-response@6.0.0
npm info linkStuff simple-swizzle@0.2.2
npm info linkStuff color-string@1.5.5
npm info linkStuff string_decoder@1.1.1
npm info linkStuff strip-ansi@3.0.1
npm info linkStuff string-width@1.0.2
npm info linkStuff strip-json-comments@2.0.1
npm info linkStuff rc@1.2.8
npm verb linkBins [
npm verb linkBins   { rc: 'cli.js' },
npm verb linkBins   '/var/www/html/node_modules/.bin',
npm verb linkBins   false
npm verb linkBins ]
npm info linkStuff tunnel-agent@0.6.0
npm info linkStuff util-deprecate@1.0.2
npm info linkStuff readable-stream@3.6.0
npm info linkStuff bl@4.1.0
npm info linkStuff readable-stream@2.3.7
npm info linkStuff are-we-there-yet@1.1.5
npm info linkStuff readable-stream@3.6.0
npm info linkStuff which-pm-runs@1.0.0
npm info linkStuff wide-align@1.1.3
npm info linkStuff gauge@2.7.4
npm info linkStuff npmlog@4.1.2
npm info linkStuff wrappy@1.0.2
npm info linkStuff once@1.4.0
npm info linkStuff end-of-stream@1.4.4
npm info linkStuff tar-stream@2.2.0
npm info linkStuff simple-get@3.1.0
npm info linkStuff pump@3.0.0
npm info linkStuff tar-fs@2.1.1
npm info linkStuff yallist@4.0.0
npm info linkStuff lru-cache@6.0.0
npm info linkStuff array-flatten@3.0.0
npm info linkStuff color@3.1.3
npm info linkStuff node-addon-api@3.1.0
npm info linkStuff prebuild-install@6.0.1
npm verb linkBins [
npm verb linkBins   { 'prebuild-install': 'bin.js' },
npm verb linkBins   '/var/www/html/node_modules/.bin',
npm verb linkBins   false
npm verb linkBins ]
npm info linkStuff semver@7.3.4
npm verb linkBins [
npm verb linkBins   { semver: 'bin/semver.js' },
npm verb linkBins   '/var/www/html/node_modules/.bin',
npm verb linkBins   false
npm verb linkBins ]
npm info linkStuff simple-get@4.0.0
npm info linkStuff sharp@0.27.2
npm timing action:build Completed in 33ms
npm info lifecycle ansi-regex@2.1.1~install: ansi-regex@2.1.1
npm info lifecycle aproba@1.2.0~install: aproba@1.2.0
npm info lifecycle base64-js@1.5.1~install: base64-js@1.5.1
npm info lifecycle chownr@1.1.4~install: chownr@1.1.4
npm info lifecycle code-point-at@1.1.0~install: code-point-at@1.1.0
npm info lifecycle color-name@1.1.3~install: color-name@1.1.3
npm info lifecycle color-convert@1.9.3~install: color-convert@1.9.3
npm info lifecycle console-control-strings@1.1.0~install: console-control-strings@1.1.0
npm info lifecycle core-util-is@1.0.2~install: core-util-is@1.0.2
npm info lifecycle deep-extend@0.6.0~install: deep-extend@0.6.0
npm info lifecycle delegates@1.0.0~install: delegates@1.0.0
npm info lifecycle detect-libc@1.0.3~install: detect-libc@1.0.3
npm info lifecycle expand-template@2.0.3~install: expand-template@2.0.3
npm info lifecycle fs-constants@1.0.0~install: fs-constants@1.0.0
npm info lifecycle github-from-package@0.0.0~install: github-from-package@0.0.0
npm info lifecycle has-unicode@2.0.1~install: has-unicode@2.0.1
npm info lifecycle ieee754@1.2.1~install: ieee754@1.2.1
npm info lifecycle buffer@5.7.1~install: buffer@5.7.1
npm info lifecycle inherits@2.0.4~install: inherits@2.0.4
npm info lifecycle ini@1.3.8~install: ini@1.3.8
npm info lifecycle is-arrayish@0.3.2~install: is-arrayish@0.3.2
npm info lifecycle isarray@1.0.0~install: isarray@1.0.0
npm info lifecycle mimic-response@2.1.0~install: mimic-response@2.1.0
npm info lifecycle decompress-response@4.2.1~install: decompress-response@4.2.1
npm info lifecycle minimist@1.2.5~install: minimist@1.2.5
npm info lifecycle mkdirp-classic@0.5.3~install: mkdirp-classic@0.5.3
npm info lifecycle napi-build-utils@1.0.2~install: napi-build-utils@1.0.2
npm info lifecycle semver@5.7.1~install: semver@5.7.1
npm info lifecycle node-abi@2.21.0~install: node-abi@2.21.0
npm info lifecycle noop-logger@0.1.1~install: noop-logger@0.1.1
npm info lifecycle number-is-nan@1.0.1~install: number-is-nan@1.0.1
npm info lifecycle is-fullwidth-code-point@1.0.0~install: is-fullwidth-code-point@1.0.0
npm info lifecycle object-assign@4.1.1~install: object-assign@4.1.1
npm info lifecycle process-nextick-args@2.0.1~install: process-nextick-args@2.0.1
npm info lifecycle safe-buffer@5.1.2~install: safe-buffer@5.1.2
npm info lifecycle set-blocking@2.0.0~install: set-blocking@2.0.0
npm info lifecycle signal-exit@3.0.3~install: signal-exit@3.0.3
npm info lifecycle simple-concat@1.0.1~install: simple-concat@1.0.1
npm info lifecycle mimic-response@3.1.0~install: mimic-response@3.1.0
npm info lifecycle decompress-response@6.0.0~install: decompress-response@6.0.0
npm info lifecycle simple-swizzle@0.2.2~install: simple-swizzle@0.2.2
npm info lifecycle color-string@1.5.5~install: color-string@1.5.5
npm info lifecycle string_decoder@1.1.1~install: string_decoder@1.1.1
npm info lifecycle strip-ansi@3.0.1~install: strip-ansi@3.0.1
npm info lifecycle string-width@1.0.2~install: string-width@1.0.2
npm info lifecycle strip-json-comments@2.0.1~install: strip-json-comments@2.0.1
npm info lifecycle rc@1.2.8~install: rc@1.2.8
npm info lifecycle tunnel-agent@0.6.0~install: tunnel-agent@0.6.0
npm info lifecycle util-deprecate@1.0.2~install: util-deprecate@1.0.2
npm info lifecycle readable-stream@3.6.0~install: readable-stream@3.6.0
npm info lifecycle bl@4.1.0~install: bl@4.1.0
npm info lifecycle readable-stream@2.3.7~install: readable-stream@2.3.7
npm info lifecycle are-we-there-yet@1.1.5~install: are-we-there-yet@1.1.5
npm info lifecycle readable-stream@3.6.0~install: readable-stream@3.6.0
npm info lifecycle which-pm-runs@1.0.0~install: which-pm-runs@1.0.0
npm info lifecycle wide-align@1.1.3~install: wide-align@1.1.3
npm info lifecycle gauge@2.7.4~install: gauge@2.7.4
npm info lifecycle npmlog@4.1.2~install: npmlog@4.1.2
npm info lifecycle wrappy@1.0.2~install: wrappy@1.0.2
npm info lifecycle once@1.4.0~install: once@1.4.0
npm info lifecycle end-of-stream@1.4.4~install: end-of-stream@1.4.4
npm info lifecycle tar-stream@2.2.0~install: tar-stream@2.2.0
npm info lifecycle simple-get@3.1.0~install: simple-get@3.1.0
npm info lifecycle pump@3.0.0~install: pump@3.0.0
npm info lifecycle tar-fs@2.1.1~install: tar-fs@2.1.1
npm info lifecycle yallist@4.0.0~install: yallist@4.0.0
npm info lifecycle lru-cache@6.0.0~install: lru-cache@6.0.0
npm info lifecycle array-flatten@3.0.0~install: array-flatten@3.0.0
npm info lifecycle color@3.1.3~install: color@3.1.3
npm info lifecycle node-addon-api@3.1.0~install: node-addon-api@3.1.0
npm info lifecycle prebuild-install@6.0.1~install: prebuild-install@6.0.1
npm info lifecycle semver@7.3.4~install: semver@7.3.4
npm info lifecycle simple-get@4.0.0~install: simple-get@4.0.0
npm info lifecycle sharp@0.27.2~install: sharp@0.27.2

> sharp@0.27.2 install /var/www/html/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

sh: node: command not found
sh: node-gyp: command not found
npm verb lifecycle sharp@0.27.2~install: unsafe-perm in lifecycle false
npm verb lifecycle sharp@0.27.2~install: PATH: /root/.nvm/versions/node/v14.15.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/var/www/html/node_modules/sharp/node_modules/.bin:/var/www/html/node_modules/.bin:/root/.nvm/versions/node/v14.15.0/bin:/sbin:/bin:/usr/sbin:/usr/bin
npm verb lifecycle sharp@0.27.2~install: CWD: /var/www/html/node_modules/sharp
npm info lifecycle sharp@0.27.2~install: Failed to exec install script
npm timing action:install Completed in 38ms
npm verb unlock done using /root/.npm/_locks/staging-dff8604cf3b8aea3.lock for /var/www/html/node_modules/.staging
npm timing stage:rollbackFailedOptional Completed in 101ms
npm timing stage:runTopLevelLifecycles Completed in 2618ms

npm verb stack Error: sharp@0.27.2 install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
npm verb stack spawn ENOENT
npm verb stack     at ChildProcess.<anonymous> (/root/.nvm/versions/node/v14.15.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
npm verb stack     at ChildProcess.emit (events.js:315:20)
npm verb stack     at maybeClose (internal/child_process.js:1048:16)
npm verb stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
npm verb pkgid sharp@0.27.2
npm verb cwd /var/www/html
npm verb Linux 4.14.219-164.354.amzn2.x86_64
npm verb argv "/root/.nvm/versions/node/v14.15.0/bin/node" "/root/.nvm/versions/node/v14.15.0/bin/npm" "install" "--verbose" "sharp"
npm verb node v14.15.0
npm verb npm  v6.14.8
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! sharp@0.27.2 install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the sharp@0.27.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm verb exit [ 1, true ]
npm timing npm Completed in 2995ms

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-03-22T14_04_57_489Z-debug.log

What is the output of running npx envinfo --binaries --system?

npx: installed 1 in 1.016s

  System:
    OS: Linux 4.14 Amazon Linux 2
    CPU: (2) x64 Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
    Memory: 2.48 GB / 3.85 GB
    Container: Yes
    Shell: 4.2.46 - /bin/bash
  Binaries:
    Node: 14.15.0 - ~/.nvm/versions/node/v14.15.0/bin/node
    npm: 6.14.8 - ~/.nvm/versions/node/v14.15.0/bin/npm
@lovell
Copy link
Owner

lovell commented Mar 22, 2021

Hello, the salient part of the error is:

sh: node: command not found

Please can you ensure that Node.js has been installed correctly. I notice you're using nvm and running as sudo/root - check that it has modified the PATH correctly - you might have run into nvm-sh/nvm#43

@lovell lovell changed the title sharp install script causing error and refusing to install "node: command not found" when using nvm and sudo/root Mar 22, 2021
@Markshall
Copy link
Author

@lovell thanks for your quick reply. Weirdly, I think I've fixed it. I changed my node version to 14.15.0 on my EC2 instance, but installed the latest version of npm using nvm install --latest-npm which brought me to npm version 7.6.3 which I think solved my issue.
I had to run npm rebuild sharp and then managed to do npm install and it seemed to work no problem for me.

Not sure what the overriding issue was, perhaps a mismatch in npm versions?

Either way, this is solved for me for now so I'll close the comment. Loving Sharp by the way!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants