Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
845 views
in Technique[技术] by (71.8m points)

How do I read a file from the local file system from inside a meteor app?

I have a meteor app that needs to periodically read a file located on the host's file system, outside of the app package. I am using node's fs to accomplish this, and it works fine on my (macOS) development machine.

However, when I run mup deploy to deploy it to my (Ubuntu 14) server, mup returns the following error after starting meteor:

Error: ENOENT: no such file or directory, open '/home/sam/data/all_data.json' at Object.fs.openSync (fs.js:652:18) at Object.fs.readFileSync (fs.js:553:33)

Does anyone know why this might be happening?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

you should follow mup documentation closely. Have you seen volumes setup in mup config? Try this to solve your issue.

Reason: mup runs app in docker without any access to host file system unless specified. Volumes setup does this for you with mup deployment.

Below is the part of mup config from http://meteor-up.com/docs.html, Everything Configured, read more to get a better idea.

    name: 'app',
    path: '../app',

    // lets you add docker volumes (optional). Can be used to
    // store files between app deploys and restarts.
    volumes: {
      // passed as '-v /host/path:/container/path' to the docker run command
      '/host/path': '/container/path',
      '/second/host/path': '/second/container/path'
    },

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...