在ubuntu 16上使用npm安装generator-jhipster时出错

时间:2017-06-06 17:30:32

标签: node.js ubuntu jhipster npm-install

我正在尝试安装jhipster来运行我已经克隆在/ home / thomas / Documents / softeng / project / CS673-Project中的存储库。我无法解析遗漏的东西。我运行的命令是sudo npm install -g generator-jhipster。 下面我已经包含了日志的完整相关部分。

11518 silly install generator-jhipster@4.5.2
11519 info lifecycle generator-jhipster@4.5.2~install: generator-jhipster@4.5.2
11520 verbose lifecycle generator-jhipster@4.5.2~install: unsafe-perm in lifecycle false
11521 verbose lifecycle generator-jhipster@4.5.2~install: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/usr/local/lib/node_modules/generator-jhipster/node_modules/.bin:/usr/local/lib/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
11522 verbose lifecycle generator-jhipster@4.5.2~install: CWD: /usr/local/lib/node_modules/generator-jhipster
11523 silly lifecycle generator-jhipster@4.5.2~install: Args: [ '-c', 'tabtab install --name jhipster --auto' ]
11524 silly lifecycle generator-jhipster@4.5.2~install: Returned: code: 1  signal: null
11525 info lifecycle generator-jhipster@4.5.2~install: Failed to exec install script
11526 verbose unlock done using /home/thomas/.npm/_locks/staging-3a08f0df5026584d.lock for /usr/local/lib/node_modules/.staging
11527 verbose stack Error: generator-jhipster@4.5.2 install: `tabtab install --name jhipster --auto`
11527 verbose stack Exit status 1
11527 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:283:16)
11527 verbose stack     at emitTwo (events.js:87:13)
11527 verbose stack     at EventEmitter.emit (events.js:172:7)
11527 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
11527 verbose stack     at emitTwo (events.js:87:13)
11527 verbose stack     at ChildProcess.emit (events.js:172:7)
11527 verbose stack     at maybeClose (internal/child_process.js:821:16)
11527 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
11528 verbose pkgid generator-jhipster@4.5.2
11529 verbose cwd /home/thomas/Documents/softeng/project/CS673-Project
11530 verbose Linux 4.4.0-53-generic
11531 verbose argv "/usr/bin/nodejs" "/usr/local/bin/npm" "install" "-g" "generator-jhipster"
11532 verbose node v4.2.6
11533 verbose npm  v5.0.3
11534 error code ELIFECYCLE
11535 error errno 1
11536 error generator-jhipster@4.5.2 install: `tabtab install --name jhipster --auto`
11536 error Exit status 1
11537 error Failed at the generator-jhipster@4.5.2 install script.
11537 error This is probably not a problem with npm. There is likely additional logging output above.
11538 verbose exit [ 1, true ]

非常感谢

2 个答案:

答案 0 :(得分:1)

我可以在你的日志中看到节点4.2.6。它太旧了。试试版本6.10.3 LTS

答案 1 :(得分:1)

我在ubuntu 16.10中运行的一些较新版本出现了同样的错误:

11518 info lifecycle generator-jhipster@4.5.5~install: Failed to exec 
install script
11519 verbose unlock done using 
/home/reginaldosantos/.npm/_locks/staging-3a08f0df5026584d.lock for 
/usr/local/lib/node_modules/.staging
11520 verbose stack Error: generator-jhipster@4.5.5 install: `tabtab install --name jhipster --auto`
11520 verbose stack Exit status 1
11520 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:283:16)
11520 verbose stack     at emitTwo (events.js:106:13)
11520 verbose stack     at EventEmitter.emit (events.js:191:7)
11520 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
11520 verbose stack     at emitTwo (events.js:106:13)
11520 verbose stack     at ChildProcess.emit (events.js:191:7)
11520 verbose stack     at maybeClose (internal/child_process.js:891:16)
11520 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
11521 verbose pkgid generator-jhipster@4.5.5
11522 verbose cwd /home/reginaldosantos
11523 verbose Linux 4.4.0-78-generic
11524 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "generator-jhipster"
11525 verbose node v6.11.0
11526 verbose npm  v5.0.3
11527 error code ELIFECYCLE
11528 error errno 1
11529 error generator-jhipster@4.5.5 install: `tabtab install --name jhipster --auto`
11529 error Exit status 1
11530 error Failed at the generator-jhipster@4.5.5 install script.
11530 error This is probably not a problem with npm. There is likely additional logging output above.
11531 verbose exit [ 1, true ]

令人惊讶的是,输出消息比详细日志更能帮助我:

/usr/local/bin/jhipster -> /usr/local/lib/node_modules/generator-jhipster/cli/jhipster.js

> generator-jhipster@4.5.5 install /usr/local/lib/node_modules/generator-jhipster
> tabtab install --name jhipster --auto

  tabtab:installer Installing completion script to bashrc directory +0ms

Error: You don't have permission to write to /home/reginaldosantos/.bashrc.
Try running with sudo instead:

  sudo /usr/local/bin/node /usr/local/lib/node_modules/generator-jhipster/node_modules/.bin/tabtab install --name jhipster --auto

oh oh Error: EACCES: permission denied, open '/home/reginaldosantos/.bashrc'
    at Error (native)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! generator-jhipster@4.5.5 install: `tabtab install --name jhipster --auto`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the generator-jhipster@4.5.5 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

在我们的安装中,npm权限肯定存在问题。 我通过将npm配置更改为全局位置来解决它:

$ mkdir ~/.npm-global

$ sudo npm config set prefix '~/.npm-global'

$ echo "export PATH=~/.npm-global/bin:\$PATH" >> ~/.profile

$ source ~/.profile

然后只需安装没有'sudo'的jhipster:

npm install -g generator-jhipster

以下是有关fixing npm permissions

的更多信息

“即使这个修复工作正常,也需要弄明白这一点。”

希望它有所帮助!