我正在尝试使用npm在OSX上安装terminalizer,但是无论是否使用sudo
都会出现错误。不确定如何继续进行修复并成功安装:
$ npm install -g terminalizer
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mona/.npm/_logs/2018-12-22T21_48_44_353Z-debug.log
Monas-MacBook-Pro:NotebooksforMLReview mona$ sudo npm install -g terminalizer
Password:
/usr/local/bin/terminalizer -> /usr/local/lib/node_modules/terminalizer/bin/app.js
> node-pty-prebuilt@0.7.6 install /usr/local/lib/node_modules/terminalizer/node_modules/node-pty-prebuilt
> prebuild-install || node scripts/install.js
prebuild-install WARN install EACCES: permission denied, access '/Users/mona/.npm'
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /Users/mona/anaconda3/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "<string>", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at maybeClose (internal/child_process.js:962:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--build_v8_with_gn=false"
gyp ERR! cwd /usr/local/lib/node_modules/terminalizer/node_modules/node-pty-prebuilt
gyp ERR! node -v v10.14.2
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-pty-prebuilt@0.7.6 install: `prebuild-install || node scripts/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-pty-prebuilt@0.7.6 install 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! /Users/mona/.npm/_logs/2018-12-22T21_49_13_893Z-debug.log
Monas-MacBook-Pro:NotebooksforMLReview mona$ vi /Users/mona/.npm/_logs/2018-12-22T21_49_13_893Z-debug.log
我有以下内容:
$ uname -a
Darwin Monas-MacBook-Pro.local 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:59:54 PDT 2018; root:xnu-4570.71.2~2/RELEASE_X86_64 x86_64
$ npm -v
6.4.1
以及日志的最后100行:
$ tail -100 /Users/mona/.npm/_logs/2018-12-22T21_49_13_893Z-debug.log
6955 info lifecycle tar-stream@1.6.2~install: tar-stream@1.6.2
6956 silly install inflight@1.0.6
6957 info lifecycle inflight@1.0.6~install: inflight@1.0.6
6958 silly install glob@7.1.3
6959 info lifecycle glob@7.1.3~install: glob@7.1.3
6960 silly install rimraf@2.6.2
6961 info lifecycle rimraf@2.6.2~install: rimraf@2.6.2
6962 silly install fs-extra@0.30.0
6963 info lifecycle fs-extra@0.30.0~install: fs-extra@0.30.0
6964 silly install pump@2.0.1
6965 info lifecycle pump@2.0.1~install: pump@2.0.1
6966 silly install simple-get@2.8.1
6967 info lifecycle simple-get@2.8.1~install: simple-get@2.8.1
6968 silly install pump@1.0.3
6969 info lifecycle pump@1.0.3~install: pump@1.0.3
6970 silly install tar-fs@1.16.3
6971 info lifecycle tar-fs@1.16.3~install: tar-fs@1.16.3
6972 silly install prebuild-install@5.2.2
6973 info lifecycle prebuild-install@5.2.2~install: prebuild-install@5.2.2
6974 silly install xtend@2.1.2
6975 info lifecycle xtend@2.1.2~install: xtend@2.1.2
6976 silly install through2@0.2.3
6977 info lifecycle through2@0.2.3~install: through2@0.2.3
6978 silly install progress-stream@1.2.0
6979 info lifecycle progress-stream@1.2.0~install: progress-stream@1.2.0
6980 silly install nugget@2.0.1
6981 info lifecycle nugget@2.0.1~install: nugget@2.0.1
6982 silly install electron-download@3.3.0
6983 info lifecycle electron-download@3.3.0~install: electron-download@3.3.0
6984 silly install y18n@4.0.0
6985 info lifecycle y18n@4.0.0~install: y18n@4.0.0
6986 silly install camelcase@5.0.0
6987 info lifecycle camelcase@5.0.0~install: camelcase@5.0.0
6988 silly install yargs-parser@11.1.1
6989 info lifecycle yargs-parser@11.1.1~install: yargs-parser@11.1.1
6990 silly install ansi-regex@3.0.0
6991 info lifecycle ansi-regex@3.0.0~install: ansi-regex@3.0.0
6992 silly install find-up@3.0.0
6993 info lifecycle find-up@3.0.0~install: find-up@3.0.0
6994 silly install is-fullwidth-code-point@2.0.0
6995 info lifecycle is-fullwidth-code-point@2.0.0~install: is-fullwidth-code-point@2.0.0
6996 silly install strip-ansi@4.0.0
6997 info lifecycle strip-ansi@4.0.0~install: strip-ansi@4.0.0
6998 silly install string-width@2.1.1
6999 info lifecycle string-width@2.1.1~install: string-width@2.1.1
7000 silly install yauzl@2.4.1
7001 info lifecycle yauzl@2.4.1~install: yauzl@2.4.1
7002 silly install extract-zip@1.6.7
7003 info lifecycle extract-zip@1.6.7~install: extract-zip@1.6.7
7004 silly install async-promises@0.2.1
7005 info lifecycle async-promises@0.2.1~install: async-promises@0.2.1
7006 silly install death@1.1.0
7007 info lifecycle death@1.1.0~install: death@1.1.0
7008 silly install deepmerge@2.2.1
7009 info lifecycle deepmerge@2.2.1~install: deepmerge@2.2.1
7010 silly install electron@2.0.16
7011 info lifecycle electron@2.0.16~install: electron@2.0.16
7012 silly install flowa@4.0.2
7013 info lifecycle flowa@4.0.2~install: flowa@4.0.2
7014 silly install fs-extra@5.0.0
7015 info lifecycle fs-extra@5.0.0~install: fs-extra@5.0.0
7016 silly install gif-encoder@0.6.1
7017 info lifecycle gif-encoder@0.6.1~install: gif-encoder@0.6.1
7018 silly install inquirer@6.2.1
7019 info lifecycle inquirer@6.2.1~install: inquirer@6.2.1
7020 silly install js-yaml@3.12.0
7021 info lifecycle js-yaml@3.12.0~install: js-yaml@3.12.0
7022 silly install node-pty-prebuilt@0.7.6
7023 info lifecycle node-pty-prebuilt@0.7.6~install: node-pty-prebuilt@0.7.6
7024 verbose lifecycle node-pty-prebuilt@0.7.6~install: unsafe-perm in lifecycle false
7025 verbose lifecycle node-pty-prebuilt@0.7.6~install: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/usr/local/lib/node_modules/terminalizer/node_modules/node-pty-prebuilt/node_modules/.bin:/usr/local/lib/node_modules/terminalizer/node_modules/.bin:/usr/local/lib/node_modules/.bin:/Users/mona/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands
7026 verbose lifecycle node-pty-prebuilt@0.7.6~install: CWD: /usr/local/lib/node_modules/terminalizer/node_modules/node-pty-prebuilt
7027 silly lifecycle node-pty-prebuilt@0.7.6~install: Args: [ '-c', 'prebuild-install || node scripts/install.js' ]
7028 silly lifecycle node-pty-prebuilt@0.7.6~install: Returned: code: 1 signal: null
7029 info lifecycle node-pty-prebuilt@0.7.6~install: Failed to exec install script
7030 timing action:install Completed in 627ms
7031 verbose unlock done using /Users/mona/.npm/_locks/staging-3a08f0df5026584d.lock for /usr/local/lib/node_modules/.staging
7032 timing stage:rollbackFailedOptional Completed in 922ms
7033 timing stage:runTopLevelLifecycles Completed in 11566ms
7034 verbose stack Error: node-pty-prebuilt@0.7.6 install: `prebuild-install || node scripts/install.js`
7034 verbose stack Exit status 1
7034 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
7034 verbose stack at EventEmitter.emit (events.js:182:13)
7034 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
7034 verbose stack at ChildProcess.emit (events.js:182:13)
7034 verbose stack at maybeClose (internal/child_process.js:962:16)
7034 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
7035 verbose pkgid node-pty-prebuilt@0.7.6
7036 verbose cwd /Users/mona/machine learning/NotebooksforMLReview
7037 verbose Darwin 17.7.0
7038 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "terminalizer"
7039 verbose node v10.14.2
7040 verbose npm v6.4.1
7041 error code ELIFECYCLE
7042 error errno 1
7043 error node-pty-prebuilt@0.7.6 install: `prebuild-install || node scripts/install.js`
7043 error Exit status 1
7044 error Failed at the node-pty-prebuilt@0.7.6 install script.
7044 error This is probably not a problem with npm. There is likely additional logging output above.
7045 verbose exit [ 1, true ]
答案 0 :(得分:0)
以下代码安装了Terminalizer
(添加了--unsafe-perm
标志)(如果有更好的解决方案,请输入。我不是npm的专家):
$ sudo npm install --unsafe-perm -g terminalizer
Password:
/usr/local/bin/terminalizer -> /usr/local/lib/node_modules/terminalizer/bin/app.js
> node-pty-prebuilt@0.7.6 install /usr/local/lib/node_modules/terminalizer/node_modules/node-pty-prebuilt
> prebuild-install || node scripts/install.js
> electron@2.0.16 postinstall /usr/local/lib/node_modules/terminalizer/node_modules/electron
> node install.js
Downloading SHASUMS256.txt
[============================================>] 100.0% of 5.39 kB (5.39 kB/s)
> node-pty-prebuilt@0.7.6 postinstall /usr/local/lib/node_modules/terminalizer/node_modules/node-pty-prebuilt
> node scripts/post-install.js
+ terminalizer@0.6.0
added 292 packages from 214 contributors in 40.879s