我正试图在Meteor JS中从服务器端生成PDF。
我添加了meteorhacks:ssr,meteorhacks:首先是npm,我的构建成功了
当我向流星添加 bryanmorgan:webshot 并运行流星时,下面是我所面临的错误,
=> Started proxy.
=> Started MongoDB.
C:\Users\a\AppData\Local\.meteor\packages\meteor-tool\1.4.4_2\mt-os.windows.x86_
32\dev_bundle\lib\node_modules\meteor-promise\promise_server.js:190
throw error;
^
Error: Builder can not write without either data or a file path or a symlink pat
h: os/packages/packages.json
at Builder.write (C:\tools\isobuild\builder.js:259:13)
at Builder.writeToGeneratedFilename (C:\tools\isobuild\builder.js:390:10)
at C:\tools\isobuild\isopack.js:1388:21
at Array.forEach (native)
at Function._.each._.forEach (C:\Users\a\AppData\Local\.meteor\packages\mete
or-tool\1.4.4_2\mt-os.windows.x86_32\dev_bundle\lib\node_modules\underscore\unde
rscore.js:79:11)
at C:\tools\isobuild\isopack.js:1381:11
at Array.forEach (native)
at Function._.each._.forEach (C:\Users\a\AppData\Local\.meteor\packages\mete
or-tool\1.4.4_2\mt-os.windows.x86_32\dev_bundle\lib\node_modules\underscore\unde
rscore.js:79:11)
at [object Object].saveToPath (C:\tools\isobuild\isopack.js:1271:9)
at C:\tools\isobuild\isopack-cache.js:380:23
at C:\tools\utils\buildmessage.js:359:18
at [object Object]._.extend.withValue (C:\tools\utils\fiber-helpers.js:89:14
)
at C:\tools\utils\buildmessage.js:352:34
at [object Object]._.extend.withValue (C:\tools\utils\fiber-helpers.js:89:14
)
at C:\tools\utils\buildmessage.js:350:23
at [object Object]._.extend.withValue (C:\tools\utils\fiber-helpers.js:89:14
)
at Object.enterJob (C:\tools\utils\buildmessage.js:324:26)
at IsopackCache._loadLocalPackage (C:\tools\isobuild\isopack-cache.js:317:18
)
at C:\tools\isobuild\isopack-cache.js:251:16
at Function.time (C:\tools\tool-env\profile.js:305:10)
at C:\tools\isobuild\isopack-cache.js:250:17
at C:\tools\utils\buildmessage.js:359:18
at [object Object]._.extend.withValue (C:\tools\utils\fiber-helpers.js:89:14
)
at C:\tools\utils\buildmessage.js:352:34
at [object Object]._.extend.withValue (C:\tools\utils\fiber-helpers.js:89:14
)
at C:\tools\utils\buildmessage.js:350:23
at [object Object]._.extend.withValue (C:\tools\utils\fiber-helpers.js:89:14
)
at Object.enterJob (C:\tools\utils\buildmessage.js:324:26)
at IsopackCache._ensurePackageLoaded (C:\tools\isobuild\isopack-cache.js:241
:20)
at C:\tools\isobuild\isopack-cache.js:77:14
at C:\tools\packaging\package-map.js:57:7
at Function._.each._.forEach (C:\Users\a\AppData\Local\.meteor\packages\mete
or-tool\1.4.4_2\mt-os.windows.x86_32\dev_bundle\lib\node_modules\underscore\unde
rscore.js:87:22)
at [object Object]._.extend.eachPackage (C:\tools\packaging\package-map.js:4
9:7)
at IsopackCache.buildLocalPackages (C:\tools\isobuild\isopack-cache.js:76:24
)
at C:\tools\project-context.js:841:25
at C:\tools\utils\buildmessage.js:359:18
at [object Object]._.extend.withValue (C:\tools\utils\fiber-helpers.js:89:14
)
at C:\tools\utils\buildmessage.js:352:34
at [object Object]._.extend.withValue (C:\tools\utils\fiber-helpers.js:89:14
)
at C:\tools\utils\buildmessage.js:350:23
at [object Object]._.extend.withValue (C:\tools\utils\fiber-helpers.js:89:14
)
at Object.enterJob (C:\tools\utils\buildmessage.js:324:26)
at ProjectContext._buildLocalPackages (C:\tools\project-context.js:840:18)
at C:\tools\project-context.js:283:9
at C:\tools\utils\buildmessage.js:359:18
at [object Object]._.extend.withValue (C:\tools\utils\fiber-helpers.js:89:14
)
at C:\tools\utils\buildmessage.js:352:34
at [object Object]._.extend.withValue (C:\tools\utils\fiber-helpers.js:89:14
)
at C:\tools\utils\buildmessage.js:350:23
at [object Object]._.extend.withValue (C:\tools\utils\fiber-helpers.js:89:14
)
at Object.enterJob (C:\tools\utils\buildmessage.js:324:26)
at ProjectContext._.extend._completeStagesThrough (C:\tools\project-context.
js:273:18)
at C:\tools\project-context.js:265:12
at Function.run (C:\tools\tool-env\profile.js:490:12)
at ProjectContext._.extend.prepareProjectForBuild (C:\tools\project-context.
js:264:13)
at C:\tools\runners\run-app.js:563:29
at C:\tools\utils\buildmessage.js:271:13
at [object Object]._.extend.withValue (C:\tools\utils\fiber-helpers.js:89:14
)
at C:\tools\utils\buildmessage.js:264:29
at [object Object]._.extend.withValue (C:\tools\utils\fiber-helpers.js:89:14
)
at C:\tools\utils\buildmessage.js:262:18
at [object Object]._.extend.withValue (C:\tools\utils\fiber-helpers.js:89:14
)
at C:\tools\utils\buildmessage.js:253:23
at [object Object]._.extend.withValue (C:\tools\utils\fiber-helpers.js:89:14
)
at Object.capture (C:\tools\utils\buildmessage.js:252:19)
at bundleApp (C:\tools\runners\run-app.js:562:31)
at [object Object]._.extend._runOnce (C:\tools\runners\run-app.js:631:35)
at [object Object]._.extend._fiber (C:\tools\runners\run-app.js:890:28)
at C:\tools\runners\run-app.js:417:12
我目前的套餐如下,
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.
meteor-base@1.0.4 # Packages every Meteor app needs to have
mobile-experience@1.0.4 # Packages for a great mobile UX
mongo@1.1.17 # The database Meteor supports right now
blaze-html-templates # Compile .html files into Meteor Blaze views
reactive-var@1.0.11 # Reactive variable for tracker
tracker@1.1.3 # Meteor's client-side reactive programming library
standard-minifier-css@1.3.4 # CSS minifier run for production mode
standard-minifier-js@2.0.0 # JS minifier run for production mode
es5-shim@4.6.15 # ECMAScript 5 compatibility for older browsers.
ecmascript@0.7.3 # Enable ECMAScript2015+ syntax in app code
kadira:flow-router # FlowRouter is a very simple router for Meteor
kadira:blaze-layout # Layout manager for blaze (works well with FlowRouter)
less@2.7.9 # Leaner CSS language
practicalmeteor:mocha # A package for writing and running your meteor app and package tests with mocha
johanbrook:publication-collector # Test a Meteor publication by collecting its output
twbs:bootstrap
ian:accounts-ui-bootstrap-3
accounts-password
aldeed:collection2
check
mizzao:user-status
gwendall:auth-client-callbacks
#dfischer:phantomjs
meteorhacks:ssr
meteorhacks:npm
npm-container
bryanmorgan:webshot
答案 0 :(得分:2)
我将您的包列表复制到一个新的新项目中并出现了一些错误。所以首先我必须删除
meteor remove meteorhacks:npm
meteor remove npm-container
第一个被弃用,第二个被拒绝。
启动应用后,我收到以下错误:
While loading bryanmorgan:webshot@1.0.0...:
error: Command failed:
/Users/jank87/.meteor/packages/meteor-tool/.1.4.4_2.cf7olq++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/bin/npm
rebuild --update-binary
Phantom installation failed { [Error: EACCES: permission denied, open
'/private/var/folders/q_/nyqwc8q55qx3c_153hvt8zy00000gn/T/mt-1wya3ja/npm/node_modules/webshot/node_modules/phantomjs/lib/location.js']
errno: -13,
code: 'EACCES',
syscall: 'open',
path:
'/private/var/folders/q_/nyqwc8q55qx3c_153hvt8zy00000gn/T/mt-1wya3ja/npm/node_modules/webshot/node_modules/phantomjs/lib/location.js'
} Error: EACCES: permission denied, open
'/private/var/folders/q_/nyqwc8q55qx3c_153hvt8zy00000gn/T/mt-1wya3ja/npm/node_modules/webshot/node_modules/phantomjs/lib/location.js'
at Error (native)
at Object.fs.openSync (evalmachine.<anonymous>:549:18)
at Object.fs.writeFileSync (evalmachine.<anonymous>:1156:15)
at writeLocationFile
(/private/var/folders/q_/nyqwc8q55qx3c_153hvt8zy00000gn/T/mt-1wya3ja/npm/node_modules/webshot/node_modules/phantomjs/install.js:161:6)
at Promise._successFn
(/private/var/folders/q_/nyqwc8q55qx3c_153hvt8zy00000gn/T/mt-1wya3ja/npm/node_modules/webshot/node_modules/phantomjs/install.js:142:5)
at Promise._call
(/private/var/folders/q_/nyqwc8q55qx3c_153hvt8zy00000gn/T/mt-1wya3ja/npm/node_modules/webshot/node_modules/phantomjs/node_modules/kew/kew.js:373:13)
at Promise._withInput
(/private/var/folders/q_/nyqwc8q55qx3c_153hvt8zy00000gn/T/mt-1wya3ja/npm/node_modules/webshot/node_modules/phantomjs/node_modules/kew/kew.js:333:25)
at Promise.resolve
(/private/var/folders/q_/nyqwc8q55qx3c_153hvt8zy00000gn/T/mt-1wya3ja/npm/node_modules/webshot/node_modules/phantomjs/node_modules/kew/kew.js:105:27)
at resolver
(/private/var/folders/q_/nyqwc8q55qx3c_153hvt8zy00000gn/T/mt-1wya3ja/npm/node_modules/webshot/node_modules/phantomjs/node_modules/kew/kew.js:409:17)
at FSReqWrap.oncomplete (evalmachine.<anonymous>:82:15)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! phantomjs@1.9.16 install: `node install.js`
npm ERR! Exit status 1
这显然来自bryanmorgan:webshot包。
正如我之前评论的那样,bryanmorgan:webshot包使用了npm包webshot。所以我删除了bryanmorgan:webshot并添加了npm包:
meteor remove bryanmorgan:webshot
meteor npm install --save webshot
这使我的meteor服务器成功重启。
现在看看bryanmorgan:webshot并尝试创建我们自己的webshot:
webshot.js
import _webshot from 'webshot';
webshot = function (url, filePath, options, callback) {
var webshotAsync = Meteor.wrapAsync(_webshot);
var callback = [].slice.apply(arguments).pop();
if (typeof callback !== 'function') {
throw new Error("Missing callback function");
}
if (arguments.length === 2) {
return webshotAsync(url, callback);
} else if (arguments.length === 3) {
return webshotAsync(url, filePath, callback);
}
webshotAsync(url, filePath, options, callback);
};
webshot("http://google.com", "./tmp/google.png", function (err) {
// screenshot saved to /tmp/google.png
console.log(err);
});
运行良好,并根据需要创建一个webshot。