如果在package.json中添加jsreport phamtom-pdf,将会失败

时间:2019-01-08 16:26:22

标签: pdf npm jsreport

如果即使具有root权限也运行npm install,则package.json中的以下jsreport将失败,并且会出现phamtom-pdf相关软件包中的mkdir权限错误

{
  "name": "jsreport-server",
  "main": "server.js",
  "scripts": {
    "start": "node server",
    "jsreport": "jsreport"
  },
  "jsreport": {
    "entryPoint": "server.js"
  },
  "dependencies": {
   "jsreport": "2.3.0",
  "jsreport-phantom-pdf": "^2.1.4"
  }
}

删除j sreport-phantom-pdf依赖项并在以后手动安装它是可以的,但这似乎很奇怪,并且破坏了package.json的目的。

--------编辑-------

npm WARN deprecated npmconf@2.1.1: this package has been reintegrated into npm and is now out of date with respect to npm
npm WARN deprecated npmconf@2.0.9: this package has been reintegrated into npm and is now out of date with respect to npm
npm WARN deprecated graceful-fs@3.0.11: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN deprecated hoek@0.9.1: The major version is no longer supported. Please update to 4.x or newer

> phantomjs@1.9.15 install /home/chnn/jsreport_git/node_modules/phantom-workers/node_modules/phantomjs
> node install.js

invalid config loglevel="notice"
/home/chnn/jsreport_git/node_modules/phantom-workers/node_modules/phantomjs/phantomjs is not writable: EACCES: permission denied, mkdir '/home/chnn/jsreport_git/node_modules/phantom-workers/node_modules/phantomjs/phantomjs'
Download already available at /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2
Extracting tar contents (via spawned process)
Removing /home/chnn/jsreport_git/node_modules/phantom-workers/node_modules/phantomjs/lib/phantom
Copying extracted folder /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2-extract-1547027030055/phantomjs-1.9.8-linux-x86_64 -> /home/chnn/jsreport_git/node_modules/phantom-workers/node_modules/phantomjs/lib/phantom
Writing location.js file
Done. Phantomjs binary available at /home/chnn/jsreport_git/node_modules/phantom-workers/node_modules/phantomjs/lib/phantom/bin/phantomjs

> puppeteer@1.11.0 install /home/chnn/jsreport_git/node_modules/puppeteer
> node install.js

ERROR: Failed to download Chromium r609904! Set "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" env variable to skip download.
{ Error: EACCES: permission denied, mkdir '/home/chnn/jsreport_git/node_modules/puppeteer/.local-chromium'
  errno: -13,
  code: 'EACCES',
  syscall: 'mkdir',
  path: '/home/chnn/jsreport_git/node_modules/puppeteer/.local-chromium' }
npm WARN jsreport-server@ No description
npm WARN jsreport-server@ No repository field.
npm WARN jsreport-server@ No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! puppeteer@1.11.0 install: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the puppeteer@1.11.0 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!     /home/chnn/.npm/_logs/2019-01-09T09_43_52_509Z-debug.log

1 个答案:

答案 0 :(得分:2)

这是puppeteer安装程序的已知错误,请参见issue#367issue #375

您可以尝试BennySLO

中提到的解决方法
sudo npm install puppeteer --unsafe-perm=true
sudo chown -R <username> node_modules/