John K
John K

Reputation: 462

Meteor packages.json error workaround when upgrading from 1.2 to 1.3 and deploying in a docker container

So this is a problem that I found an answer to instead of asking a question, so hopefully that's allowed. I have a meteor app that was upgraded from 1.2 to 1.3 and deployed into a docker container. I was getting this error:

/root/.meteor/packages/templating/.1.1.7.kbxyh0++os+web.browser+web.cordova/plugin.compileTemplatesBatch.os/npm/node_modules/meteor/promise/node_modules/meteor/promise/node_modules/meteor-promise/promise_server.js:116
      throw error;
            ^
Error: Builder can not write without either data or a file path or a symlink path: os/packages/packages.json
    at Builder.write (/tools/isobuild/builder.js:251:13)
    at Builder.writeToGeneratedFilename (/tools/isobuild/builder.js:382:10)
    at /tools/isobuild/isopack.js:1400:27
    at Array.forEach (native)
    at Function._.each._.forEach (/root/.meteor/packages/meteor-tool/.1.3.0_3.fc5itk++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
    at _.each.builder.copyDirectory.from (/tools/isobuild/isopack.js:1372:11)
    at Array.forEach (native)
    at Function._.each._.forEach (/root/.meteor/packages/meteor-tool/.1.3.0_3.fc5itk++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
    at /tools/isobuild/isopack.js:1263:9
    at Isopack._.extend.saveToPath (/tools/isobuild/isopack.js:1641:7)
    at /tools/isobuild/isopack-cache.js:323:23
    at /tools/utils/buildmessage.js:359:18
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at /tools/utils/buildmessage.js:352:34
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at /tools/utils/buildmessage.js:350:23
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at Object.enterJob (/tools/utils/buildmessage.js:324:26)
    at [object Object]._loadLocalPackage (/tools/isobuild/isopack-cache.js:260:18)
    at /tools/isobuild/isopack-cache.js:194:16
    at Function.time (/tools/tool-env/profile.js:305:10)
    at /tools/isobuild/isopack-cache.js:193:17
    at /tools/utils/buildmessage.js:359:18
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at /tools/utils/buildmessage.js:352:34
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at /tools/utils/buildmessage.js:350:23
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at Object.enterJob (/tools/utils/buildmessage.js:324:26)
    at [object Object]._ensurePackageLoaded (/tools/isobuild/isopack-cache.js:184:20)
    at /tools/isobuild/isopack-cache.js:75:14
    at /tools/packaging/package-map.js:57:7
    at Function._.each._.forEach (/root/.meteor/packages/meteor-tool/.1.3.0_3.fc5itk++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:87:22)
    at [object Object].eachPackage (/tools/packaging/package-map.js:49:7)
    at [object Object].buildLocalPackages (/tools/isobuild/isopack-cache.js:74:24)
    at /tools/project-context.js:758:25
    at /tools/utils/buildmessage.js:359:18
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at /tools/utils/buildmessage.js:352:34
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at /tools/utils/buildmessage.js:350:23
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at Object.enterJob (/tools/utils/buildmessage.js:324:26)
    at ProjectContext._.extend._buildLocalPackages (/tools/project-context.js:757:18)
    at /tools/project-context.js:278:9
    at /tools/utils/buildmessage.js:359:18
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at /tools/utils/buildmessage.js:352:34
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at /tools/utils/buildmessage.js:350:23
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at Object.enterJob (/tools/utils/buildmessage.js:324:26)
    at ProjectContext._completeStagesThrough (/tools/project-context.js:268:18)
    at /tools/project-context.js:260:12
    at Function.run (/tools/tool-env/profile.js:489:12)
    at ProjectContext.prepareProjectForBuild (/tools/project-context.js:259:13)
    at /tools/runners/run-app.js:557:29
    at /tools/utils/buildmessage.js:271:13
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at /tools/utils/buildmessage.js:264:29
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at /tools/utils/buildmessage.js:262:18
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at /tools/utils/buildmessage.js:253:23
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at Object.capture (/tools/utils/buildmessage.js:252:19)
    at bundleApp (/tools/runners/run-app.js:556:31)
    at AppRunner._runOnce (/tools/runners/run-app.js:634:35)
    at AppRunner._fiber (/tools/runners/run-app.js:887:28)
    at /tools/runners/run-app.js:411:12

My first thought was that it was a caching issue with docker (http://thenewstack.io/understanding-the-docker-cache-for-faster-builds/) not pulling down the latest meteor version from install.meteor.com, and thus some weird version mismatch. I solved that by changing the line in the Dockerfile to be:

RUN curl https://install.meteor.com/ | sh; echo "version 1.3"

Awesome, that fixed that problem and now I had the current meteor version, but I was still getting the error. At this point I just needed my deployment to work because we're in the middle of a sprint, and here we arrive at one of my hackiest solutions to date:

I added a symlink inside of the packages dir named packages.json that pointed to the packages.json in the main dir of my project.

If anyone wants to comment on what the root cause of the problem is, and an actual solution that would be awesome, but hopefully this helps someone else who needs a workaround.

Upvotes: 6

Views: 1240

Answers (1)

jeggah
jeggah

Reputation: 1

First get rid of the offending packages:

meteor remove npm-container meteor remove meteorhacks:npm

Then you need to fix any old NpmRequire code to do it the new way. In Meteor 1.3, you can now use npm like any node.js app.

meteor npm init to create package.json

meteor npm install --save underscore to add the dependency in your app

Now you can import it into your app via:

import _ from 'underscore' or var _ = require('underscore')

See http://guide.meteor.com/using-packages.html for a full explanation

Upvotes: 0

Related Questions