3

I know how to package and then deploy meteor application. But recently for one project i'm stuck at an error which i couldn't resolve.

Steps I followed for package and deploy of my meteor app:

    1. meteor build package 
    2. cd package
    3. tar -xf inventoryTool.tar.gz
    4. cd bundle/programs/server
    5. npm install
    6. cd ../..
    7. PORT=<port> MONGO_URL=mongodb://127.0.0.1:27017/dbName ROOT_URL=http://<ip> node main.js

Here is the log for the error when i run the npm install(STEP 5) command. Is there anything missing in my execution?. I'm not using the fibers package anywhere in my project. Does anyone have solution to this problem? Thanks in advance.

Snkini
  • 571
  • 1
  • 5
  • 16

1 Answers1

2

Why this happens (a lot)?

Your local version of node is v8.9.4. When using the build command, you will export your application and build the code against this exact node version. Your server environment will require this exact version, too.

An excerpt from the custom deployment section of the guide:

Depending on the version of Meteor you are using, you should install the proper version of node using the appropriate installation process for your platform. To find out which version of node you should use, run meteor node -v in the development environment, or check the .node_version.txt file within the bundle generated by meteor build.

Even if you don't use fibers explicitly it will be required to run your Meteor app on the server correctly.

So what to do?

In order to solve this, you need to

a) ensure that your local version of node exactly matches the version on the server

b) ensure that you build against the server's architecture (see build command)

To install a) the very specific node version on your server you have two options:

Option I. Use n, as described here. However this works only if your server environment uses node and not nodejs (which depends on how you installed nodejs on the server).

II. To install a specific nodejs version from the repositories, you may do the following:

$ cd /tmp
$ wget https://deb.nodesource.com/node_8.x/pool/main/n/nodejs/nodejs_8.9.4-1nodesource1_amd64.deb
$ apt install nodejs_8.9.4-1nodesource1_amd64.deb

If you are not sure, which of both are installed on your server, check node -v and nodejs -v. One of both will return a version. If your npm install still fails, check the error output and if it involves either node or nodejs and install the desired distribution using the options above.

To build b) against the architecture on your server, you should use the --architecture flag in your build command.

Jankapunkt
  • 8,128
  • 4
  • 30
  • 59
  • Thanks for ur response.I got the point that both version should be same to build package of meteor app, But why dosen't it obstruct the `meteor run`?. I tried the steps which you mentioned, since i'm using REHL 6.6 enterprise versions server i couldn't install it using those command. – Snkini Mar 05 '18 at 13:56
  • I see. The install routine is implying a debian based distribution so it won't work on REHL but using `n` should be fine. Does your `npm install` script complete without error now? – Jankapunkt Mar 05 '18 at 14:04
  • `[root@localhost tmp]# npm install nodejs_8.9.4-1nodesource1_amd64.deb npm ERR! code E404 npm ERR! 404 Not Found: nodejs_8.9.4-1nodesource1_amd64.deb@latest` this is the output i get. – Snkini Mar 05 '18 at 14:14
  • 1
    You can't install the nodejs distribution this way. Please use **option I.** to install the version via `n` as described in the linked blog article. – Jankapunkt Mar 05 '18 at 14:15