Error when deploying bare-bones package to remote server

Hello Meteor helpmates!

I am doing my best to deploy the basic out-of-the-box Meteor app to a remote server. This is running on Ubuntu 16.04 and is managed by Plesk Onyx. I am following the tutorial at (PhusionPassenger.com)[https://www.phusionpassenger.com/library/walkthroughs/deploy/meteor/ownserver/nginx/oss/xenial/deploy_app.html].

When I run …

$ cd bundle/programs/server
$ npm install --production

… I get the following error message:

npm WARN meteor-dev-bundle@0.0.0 No description
npm WARN meteor-dev-bundle@0.0.0 No repository field.
npm WARN meteor-dev-bundle@0.0.0 No license field.
npm ERR! Linux 4.4.0-97-generic
npm ERR! argv "/opt/plesk/node/7/bin/node" "/opt/plesk/node/7/bin/npm" "install" "--production"
npm ERR! node v7.4.0
npm ERR! npm  v4.0.5
npm ERR! code ELIFECYCLE
npm ERR! meteor-dev-bundle@0.0.0 install: `node npm-rebuild.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the meteor-dev-bundle@0.0.0 install script 'node npm-rebuild.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the meteor-dev-bundle package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node npm-rebuild.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs meteor-dev-bundle
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls meteor-dev-bundle
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/vhosts/russkiy.fun/node.russkiy.fun/bundle/programs/server/npm-debug.log

I note the line: “Make sure you have the latest version of node.js and npm installed.” The versions of node.js and npm on this remote server are more recent than the versions on my development machine, where Meteor runs happily.

Server:

$ node --version
v7.4.0
$ npm --version
4.0.5

Development:

$ node --version
v4.8.4
$ npm --version
2.15.11

Is this the cause of the problem? If Meteor should be able to run with these more recent versions, where should I send a report on this issue?

Thanks in advance for your insights,

James

Hi James,

Meteor won’t play nice without the version it requires. If it’s a Meteor 1.5 app, use v4.8.4.

Otherwise, you could go for one of the 1.6 release candidates (which for me run fine) and enjoy node 8 goodness. Then just update to 1.6 itself when it’s finished.

Hope this helps.

Thanks korus90!

I’ve installed Node.js v4.8.4 and npm 2.5.11 in addition to v7.4.0 and v4.0.5, and told the meteor user to use these legacy versions, and npm install now runs with no errors.

1 Like

@blackslate, Glad it is working for you.

When checking the versions that meteor is using you must use the meteor command. The versions of node and npm that you have in your environment are not used by meteor.

To get the versions that meteor is using do this:

meteor node --version
meteor npm --version

Background

Meteor uses a concept called a “dev bundle”. Essentially, it is all the tools that Meteor requires to build.

Meteor uses these tools for the meteor commands. The way they ship it and use it means that you can have multiple versions of Meteor on your dev machine without polluting any of your other tools on your development machine. You can even have your own version of node & npm sitting around and they do not interfere with meteor’s version. Slick!!

For example, you can find the meteor builds on your machine here:

  • Windows:C:\Users\<USERNAME>\AppData\Local\.meteor\packages\meteor-tool\
  • *nix: ~/.meteor/packages/meteor-tool/

Then dig into a version and find the dev bundle, e.g.:
1.5.2_2\mt-os.windows.x86_32\dev_bundle

In the bin directory you will find the version of node and npm that meteor uses for that version. This is what is run when you type meteor npm --version. And this is the directory where meteor runs from when it is doing node operations.

Script to install NPM and Node properly (for Debian, but should work for Ubuntu, double check before use):

#!/bin/bash
version=$1
apt-get install -y build-essential python libssl-dev pkg-config wget
wget "https://nodejs.org/dist/$version/node-$version.tar.gz"
tar -xf "node-$version.tar.gz"
cd "node-$version/"
./configure
make
make install

# Make sure we use proper NPM
npm install -g npm@4
cd ../
rm -Rf "node-$version.tar.gz" "node-$version/"

Save it for example as update-node.sh, and make it executable:

chmod +x ./update-node.sh

Then install node@4.8.4:

./update-node.sh v4.8.4

Building Meteor App Command:

meteor build ../build/ --architecture os.linux.x86_64

Deploy script (for NGINX + Phusion Passenger):

### Extract files from archive
### Change APPNAME to the name of your archive
tar -xzf APPNAME.tar.gz

### Create public directory for Nginx and Phusion
### Nginx's config should point to that directory
mkdir -p ./bundle/public

### Copy all static assets to Nginx's public directory
cp ./bundle/programs/web.browser/*.css ./bundle/public/
cp ./bundle/programs/web.browser/*.js ./bundle/public/
cp ./bundle/programs/web.browser/*.html ./bundle/public/
cp -R ./bundle/programs/web.browser/app/* ./bundle/public/
cp -R ./bundle/programs/web.browser/packages ./bundle/public/

chmod -R 744 ./bundle
chmod 755 ./bundle

### Uncomment and change "appuser" to the name of the user
### which is used to spawn node.js process (security basics, process rights restriction)
### chown -R appuser:appuser ./bundle

### Prepare directories at WWW 
mkdir -p /var/www/appname/public/
mkdir -p /var/www/appname/programs/web.browser/

### Copy files to WWW directory
### using rsync - Make sure it's installed
### avoiding .git directory "if exists"
rsync -qauh ./bundle/ /var/www/appname --exclude=".git"

### Go to bundle and install NPM dependencies
cd /var/www/appname/programs/server
npm install --production

### Get back from app's direcory
### cd - 


### Uncomment and change "appuser" to the name of the user
### which is used to spawn node.js process (security basics, process rights restriction)
### chown -R appuser:appuser /var/www/appname

### Fix permissions if any went broken
chmod -R 744 /var/www/appname
chmod 755 /var/www/appname
chmod -R 755 /var/www/appname/public

### Remove bundle directory
### rm -Rf ./bundle

### Restart Phusion passenger
passenger-config restart-app /var/www/appname
### Show its status
passenger-status -v
### Display logs - to check if everything is okay
tail -n 25 -f /var/log/nginx/error.log

I have found this old gist - might be helpful for you too.
Hope this will be helpful