Error: Cannot find module 'socket.io/node_modules/redis' on Mac - django

I am trying to run this example (http://maxburstein.com/blog/realtime-django-using-nodejs-and-socketio/) but I'm getting this error:
module.js:340
throw err;
^
Error: Cannot find module 'socket.io/node_modules/redis'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/felipemoran/Desktop/django-realtime-tutorial-master/nodejs/chat.js:7:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
What I did so far was:
Unpack the source files - ok
Start Redis server (by typing on terminal redis-server) - ok
Start Django server (by typing on a different window python manage.py runserver, while in the propper folder) - ok
The next step would be, on a third terminal window, run the command node chat.js, while in the folder nodejs folder from the example files, but I'm getting this error.
I'm on Mac OS X Maverics, I installed node.js from the official mac installer and I installed socket.io using the npm command.
I also tried running rpm install socket.io -g , rpm install -g socket.io, those two with sudo and runing these commands from the nodejs folder but still no success.
Thanks!

Running npm install socket.io installs the latest version from npm which is now 1.1.0. Your tutorial uses version 0.9 and a lot changed from that to 1.0, including how to use the Redis adapter. Since the tutorial does not use a package.json to manage the dependencies you ended up with wrong version.
You can either upgrade your server code to work with latest socket.io (for which you need to install socket.io-redis) or check the latest version from the 0.9 branch by running npm view socket.io versions and then install npm install socket.io#0.9.17.
And please remove the global installations, they will cause you gray hair later (npm uninstall -g socket.io).

Related

AWS Elastic Beanstalk invalid binary packages

I am working on migrating a project from Heroku to AWS. I keep getting an error after deployment saying: 'invalid ELF header'. I have found posts with similar issues when using AWS Lambda, but I do not understand why I would have an issue with binary packages in Elastic Beanstalk.
Doesn't Elastic Beanstalk provide a configured environment to run my code similar to Docker? I feel like this problem must be more complex as I cannot find anyone else with this issue in Elastic Beanstalk.
Here is the exact error I am getting:
Error: /var/app/current/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
at Object.Module._extensions..node (internal/modules/cjs/loader.js:730:18)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/var/app/current/node_modules/bcrypt/bcrypt.js:6:16)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! beer#0.1.0 start: `node server/server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the beer#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/.npm/_logs/2019-04-15T00_54_06_983Z-debug.log
I am working on a Mac, my code contains both client and server code written in React, node.js, and SQL. I am uploading my code via a ZIP file containing multiple folders, including node_modules/.
Some libraries are sensitive to the operating system and / or CPU architecture on which they are built. This is especially true of modules implemented in low-level languages, or that link to system libraries. In this case, you appear to be using bcrypt which is largely written in C++.
This is one reason that the zip file you upload to Elastic Beanstalk shouldn't include your node_modules/ folder (or anything else that Git is ignoring). The easiest way to create a zip for uploading to Elastic Beanstalk is probably to use git archive:
git archive -v -o myapp.zip --format=zip HEAD
This will respect your ignores, whereas manually zipping will include them.
Your archive should include package.json and package-lock.json in its root. Elastic Beanstalk will install its own node_modules/ from these files if they are present. This should ensure that all libraries are compatible with its operating system.

Windows 10 - vagrant plugin install vagrant-aws - The "libxml2" package isn't available. (RuntimeError)

Trying to install aws plugin for vagrant. Getting a dependency error.
Logs show...
find_executable: checking for xml2-config... -------------------- no
--------------------
"pkg-config --exists libxml2"
package configuration for libxml2 is not found
Console output:
C:\Users\jkittell\Documents\Schedule3> vagrant plugin install vagrant-aws
Installing the 'vagrant-aws' plugin. This can take a few minutes...
Building native extensions. This could take a while...
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:
ERROR: Failed to build gem native extension.
current directory: C:/Users/jkittell/.vagrant.d/gems/2.4.4/gems/ovirt-engine-sdk-4.2.4/ext/ovirtsdk4c
C:/HashiCorp/Vagrant/embedded/mingw64/bin/ruby.exe -r ./siteconf20181002-19764-xj4q7a.rb extconf.rb
checking for xml2-config... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/HashiCorp/Vagrant/embedded/mingw64/bin/$(RUBY_BASE_NAME)
--with-libxml2-config
--without-libxml2-config
--with-pkg-config
--without-pkg-config
extconf.rb:29:in `<main>': The "libxml2" package isn't available. (RuntimeError)
To see why this extension failed to compile, please check the mkmf.log which can be found here:
C:/Users/jkittell/.vagrant.d/gems/2.4.4/extensions/x64-mingw32/2.4.0/ovirt-engine-sdk-4.2.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in C:/Users/jkittell/.vagrant.d/gems/2.4.4/gems/ovirt-engine-sdk-4.2.4 for inspection.
Results logged to C:/Users/jkittell/.vagrant.d/gems/2.4.4/extensions/x64-mingw32/2.4.0/ovirt-engine-sdk-4.2.4/gem_make.out
PS C:\Users\jkittell\Documents\Schedule3>
I did a google search and found a hotfix for this.
Gem file available here.
Just do a vagrant plugin install ~/PATH/TO/vagrant-aws-0.8.0.gem
I had to install fog-aws plugin first and then it worked.
vagrant plugin install fog-aws
Console output:
PS C:\Users\jkittell\Documents\Schedule3> vagrant plugin install ..\..\Downloads\vagrant-aws-0.8.0.gem
Installing the '..\..\Downloads\vagrant-aws-0.8.0.gem' plugin. This can take a few minutes...
Fetching: iniparse-1.4.4.gem (100%)
Fetching: fog-core-2.1.2.gem (100%)
Fetching: fog-aws-3.3.0.gem (100%)
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:
conflicting dependencies fog-aws (= 2.0.1) and fog-aws (~> 3.0)
Activated fog-aws-3.3.0
which does not match conflicting dependency (= 2.0.1)
Conflicting dependency chains:
vagrant-aws (= 0.8.0), 0.8.0 activated, depends on
fog-aws (~> 3.0), 3.3.0 activated
versus:
fog-aws (= 2.0.1)
PS C:\Users\jkittell\Documents\Schedule3> vagrant plugin install fog-aws
Installing the 'fog-aws' plugin. This can take a few minutes...
Successfully uninstalled dry-inflector-0.1.2
Successfully uninstalled fog-aliyun-0.3.2
Successfully uninstalled fog-atmos-0.1.0
Successfully uninstalled fog-aws-2.0.1
Successfully uninstalled fog-brightbox-0.16.1
Successfully uninstalled fog-cloudatcost-0.1.2
Successfully uninstalled fog-core-1.45.0
Successfully uninstalled fog-digitalocean-0.4.0
Removing console
Removing setup
Successfully uninstalled fog-dnsimple-1.0.0
Successfully uninstalled fog-dynect-0.0.3
Successfully uninstalled fog-ecloud-0.3.0
Successfully uninstalled fog-google-0.1.0
Successfully uninstalled fog-internet-archive-0.0.1
Successfully uninstalled fog-joyent-0.0.1
Successfully uninstalled fog-local-0.6.0
Successfully uninstalled fog-openstack-0.3.6
Successfully uninstalled xml-simple-1.1.5
Installed the plugin 'fog-aws (3.3.0)'!
PS C:\Users\jkittell\Documents\Schedule3> vagrant plugin install ..\..\Downloads\vagrant-aws-0.8.0.gem
Installing the '..\..\Downloads\vagrant-aws-0.8.0.gem' plugin. This can take a few minutes...
Installed the plugin 'vagrant-aws (0.8.0)'!
PS C:\Users\jkittell\Documents\Schedule3> vagrant plugin install vagrant-aws
Installing the 'vagrant-aws' plugin. This can take a few minutes...
Installed the plugin 'vagrant-aws (0.8.0)'!
PS C:\Users\jkittell\Documents\Schedule3>
Try using:
vagrant plugin install fog-aws
vagrant plugin update
vagrant plugin install vagrant-aws
This should upgrade fog to a version 3.5 or greater

ENOENT error when doing ionic start

I upgraded to beta.23 and started to get an error when created a new project using 'ionic start foo --v2 --verbose'.
The error in red says
"Unable to spawn commandError: spawn npm ENOENT (CLI v2.0.0-beta.23)."
I have npm installed and can run from Windows 8 cmd line.
I tried upgrade to node v5.9.1.
I confirmed npm is in the PATH environment variable and can run npm from cmd shell.
Any ideas how to fix or debug further would be appreciated.
Here is the complete output:
C:\ionic2>ionic start foo --v2 --verbose
Task setting: title=start, name=start, summary=Starts a new Ionic project in the
specified PATH, [options]=any flags for the command, <PATH>=directory for the n
ew project, [template]=Starter templates can either come from a named template,
(ex: tabs, sidemenu, blank),
a Github repo, a Codepen url, or a local directory.
Codepen url,
Defaults to Ionic "tabs" starter template, --appname|-a=Human readable name for
the app (Use quotes around the name), --id|-i=Package name for <widget id> confi
g, ex: com.mycompany.myapp, title=Skip npm package installation, boolean=true, t
itle=Create a basic structure without Cordova requirements, boolean=true, title=
Setup the project to use Sass CSS precompiling, boolean=true, title=List starter
templates available, boolean=true, --io-app-id=The Ionic.io app ID to use, --te
mplate|-t=Project starter template, boolean=true, title=Start a Ionic v2 project
, boolean=true, title=(with --v2 only) Use TypeScript in starter, --zip-file|-z=
URL to download zipfile for starter template, module=./ionic/start, disableChang
ePwd=true
Utils.preprocessCliOptions _=[start, foo], skip-npm=false, no-cordova=false, w=f
alse, sass=false, s=false, list=false, l=false, v2=true, v=false, typescript=fal
se, -ts=false, verbose=true, $0=C:\Program Files\nodejs\node.exe C:\Users\bradtk
e\AppData\Roaming\npm\node_modules\ionic\bin\ionic
One awesome Ionic app coming right up...
Creating Ionic app in folder C:\ionic2\foo based on tabs project
Downloading: https://github.com/driftyco/ionic2-app-base/archive/master.zip
[=============================] 100% 0.0s
Downloading: https://github.com/driftyco/ionic2-starter-
tabs/archive/master.zip
[=============================] 100% 0.0s
Installing npm packages...
Running exec command: npminstall
Utils.fail Unable to run spawn commandError: spawn npm ENOENT undefined
Utils.fail stack undefined
Utils.errorHandler is set, calling that now
Cli.Utils.errorHandler msg Unable to run spawn commandError: spawn npm ENOENT st
ring
Unable to run spawn commandError: spawn npm ENOENT (CLI v2.0.0-beta.23)
Your system information:
Cordova CLI: 6.1.0 (cordova-lib#undefined)
Ionic CLI Version: 2.0.0-beta.23
Ionic App Lib Version: 2.0.0-beta.13
OS: Windows 8.1
Node Version: v5.9.1
Regards,
bruce
I have the exact same issue. Worked in beta 22.
Reverting to the earlier beta resolved the issue:
npm install -g ionic#2.0.0-beta.22
Move into folder of your application and run npm install. I don't know what is happening but sound like start script trying to execute npminstall rather than npm install:
Installing npm packages...
Running exec command: npminstall
This is a known issue with the CLI on windows. Downgrading to cli beta22 can work as workaround for now, but this will be fixed in the next release
Upgrading npm worked for me.
npm install -g npm

Could not start watchman; falling back to NodeWatcher for file system events

I get the below error message while I switch between my ember applications:
version: 2.4.2
Could not start watchman; falling back to NodeWatcher for file system events.
Visit ember-cli.com for more info.
Livereload server on http://localhost:49153
Could not serve on http://localhost:4200. It is either in use or you do not have permission.
Here are the packages that I have setup on my machine:
npm --version
2.14.20
bower --version
1.7.7
ember --version
2.4.2
node: 4.4.0
os: linux x64
Ember-cli (starting from release 0.1.3) requires watchman or some other service (e.g. NodeWatcher) for file watching.
You can find this info in the ember-cli release 0.1.3 changelog:
https://github.com/ember-cli/ember-cli/releases/tag/v0.1.3
Although I believe you could use your Ember app without watchman, could you confirm that you already have watchman installed?
If not, here's what works fine for me in Ubuntu 64bit:
// installing watchman from source
git clone https://github.com/facebook/watchman.git
cd watchman
./autogen.sh
./configure
make
sudo make install
if you still have problems after installing try also resetting your watchman configuration:
watchman watch-del-all
watchman watch-del /home/myproject // your project folder goes here...
watchman watch-project /home/myproject // your project folder goes
full installation instructions regarding watchman can also be found here
https://facebook.github.io/watchman/docs/install.html

missing template processor ember

Very new on using ember (and a js framework in general)
i'm following the official guide on the ember site, installed the ember-cli and create a test app but when i 'server' it a get this message:
Missing template processor
Error: Missing template processor
at module.exports.preprocessTemplates C:\Users\vittorio\AppData\Roaming\npm \node_modules\ember-cli\lib\preprocessors.js:164:11)
at EmberApp._processedTemplatesTree (C:\Users\vittorio\AppData\Roaming\npm\node_modules\ember-cli\lib\broccoli\ember-app.js:567:10)
at EmberApp.appAndDependencies (C:\Users\vittorio\AppData\Roaming\npm\node_modules\ember-cli\lib\broccoli\ember-app.js:808:24)
at EmberApp.javascript (C:\Users\vittorio\AppData\Roaming\npm\node_modules\ember-cli\lib\broccoli\ember-app.js:882:34)
at EmberApp.toArray (C:\Users\vittorio\AppData\Roaming\npm\node_modules\ember-cli\lib\broccoli\ember-app.js:1248:10)
at EmberApp.toTree (C:\Users\vittorio\AppData\Roaming\npm\node_modules\ember-cli\lib\broccoli\ember-app.js:1270:30)
at Object.<anonymous> (e:\web\apps\test_ember\Brocfile.js:20:22)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
I could not find easy enough info for a beginner and i'm just stuck.
Some info about my environment on windows 7:
$ ember --version
version: 0.2.3
node: 0.12.0
npm: 2.7.6
I case anyone else is getting the same error when trying "ember server" command and the solution above doesn't work (didn't work for me). I realized I had to run:
npm install
bower install
before running the server; after doing this I was able to run "ember server" and worked good.
ember-cli projects can be finicky about its module versions. Try to update your package caches and reinstall ember-cli:
bower cache clean && npm cache clean && npm install -g ember-cli