Pusher.subscribe() is not a function from the server side? - javascript

I'm trying to use pusher.subscribe() on the server side, but Pusher is only for client side.
I found this: https://github.com/pusher/pusher-http-node
Which allows us to set up a pusher for the server side. However, the readme is outdated and I can't set it up.
Running this command
npm install pusher --prefix cloud/modules
Only creates: cloud/modules/etc and cloud/modules/node_modules.
This means I cant run
$ cd cloud/modules/pusher
$ npm run parse-build
Please help!

try to use cd cloud/modules/node_modules/pusher and then npm run parse-build it will create build for Parse cloud
'Creating build for Parse Cloud.' && webpack --config=./parse.webpack.js Creating build for Parse Cloud. sh: webpack: command not found
Install webpack using npm install -g webpack globally or locally to install webpack local for the project npm install -D to install all dev dependencies in your cd cloud/modules/node_modules/pusher directory.It is recommended to install webpack locally so that you need not to stick to a particular version for different projects.

You can't subscribe with Pusher you can only trigger and some other functions
if you want to subscribe from the server side(nodejs e.t.c)
use pusher-js
npm i pusher-js or yarn add pusher-js

Related

How to insert dependencies in local package if npm package is installed globally

I have installed few npm packages globally but it does not show any dependencies in any of my package.json files. Which npm command should I use to apply dependencies in all of my package.json files?
Globally installed dependencies won't list in your local package.json file. You should still be able to use them requiring/importing into your project.
if you want to save a dependency in your package.json as well when you install it, us --save flag with npm install command.
for example
npm install --save express
It is not recommended to add a package which is installed globally to locally or vice versa.
When a package is installed globally, it is normally used as a command in the terminal. For example, create-react-app or express-generator. You might install these packages globally to use them as commands in the terminal to build React or Express app (with default scaffold).
When a package is installed locally, it means you want to use it within the application. For example, jsonwebtoken. You should install this package locally so that it can be used within the application and when somebody else clones your project they can install this package as well via npm install command.
So, the suggestion is, install the package globally if you're going to use it as a command, else install the package locally within the application. Don't mix them.

does npm install command for node package manager runs npm build automatically

I have integrated a reusable node js project to azure and published the node project to azure artifact store for npm using command 'npm publish'.
And i have a azure task in pipeline which uses this reusable package in my main project with yaml content like below:
npm install <my reusable package name from internal azure npm registry>
npm install //this installs all other packages based on main project's package.json
Does npm command 'npm install ' runs 'npm build' command right after downloading package ? if it does then i do not want to buid my npm package before publishing.
I want to make sure when someone install my reusable package the dist folder is available.
e.g. When i install npm package 'vue-tabulator' after installation i noticed it populated dist folder. I am not sure if this happens for all the packages.

Can`t make gRPC work with Electron.js

I`m making an Electron app that should connect by grpc to remote host and call some functions from there.
But I keep getting the following error:
Uncaught Error: A dynamic link library (DLL) initialization routine failed.
\?\D:\Projects\demo-app\node_modules\grpc\src\node\extension_binary\grpc_node.node
I tried to:
establish grpc connection from main and from renderer processes of Electron
install dependencies as npm install --unsafe-perm
but nothing works.
Error
The gRPC package is distributed with precompiled binaries for Electron, including on Windows, but you have to specify that you're using Electron when you do the installation. The following should work:
npm install grpc --runtime=electron --target=<electron version>
If you're using a native module, you'll need to rebuild them against your current electron node version.
There is a package called electron-rebuild that will do this for you. Basic instructions:
npm install --save-dev electron-rebuild
Then, whenever you install a new npm package, rerun electron-rebuild:
./node_modules/.bin/electron-rebuild
Or if you're on Windows:
.\node_modules\.bin\electron-rebuild.cmd

How do I build backbone boilerplate with grunt?

I'm trying to build the backbone boilerplate project found here: https://github.com/backbone-boilerplate/backbone-boilerplate
I'm having some issues getting it to build properly. Here are the steps I've done which are the steps on the backbone-boilerplate wiki:
git clone https://github.com/backbone-boilerplate/backbone-boilerplate.git
cd backbone-boilerplate
sudo npm install -gq bower
sudo npm install -q
sudo npm install -gq grunt-cli
sudo grunt
At this point I get:
>> Local Npm module "grunt-cli" not found. Is it installed?
Warning: Task "requirejs" not found. Use --force to continue.
Aborted due to warnings.
Any ideas how to get this to build properly?
Specifying depth seems to work:
$ git clone --depth 1 https://github.com/backbone-boilerplate/backbone-boilerplate.git
$ npm install
$ grunt
Also you may want to restart your terminal if that is your first time installing grunt-cli
You're running grunt under elevated privileges. Our documentation for building here:
https://github.com/backbone-boilerplate/backbone-boilerplate#build-process
... has you run that command under your own user. Give that a shot!
You need to ensure you build dependencies with bower, not just the node dependencies.
Getting Started
# Using Git, fetch only the latest commits. You won't need the full history
# for your project.
git clone --depth 1 https://github.com/backbone-boilerplate/backbone-boilerplate
# Move the repository to your own project name.
mv backbone-boilerplate my-project
Updating Dependencies
# Install global dependencies. Depending on your user account you may need to
# gain elevated privileges using something like `sudo`.
npm install -g grunt-cli bower
# Optionally install coveralls (integration is baked in with Travis CI).
npm install -g coveralls
# Install NPM dependencies.
npm install
# Install Bower dependencies. ** THIS IS THE ONE YOU'VE MISSED **
bower install
Build Process
# To run the build process, run the default Grunt task.
grunt
# Run a build and test the now optimized assets.
grunt default server:release
If you have node installed correctly this should work like a charm.

Express module not found when installed with NPM

When I try to run the app.js file created by express, I get the following error:
$ node app.js
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'express'
at Function._resolveFilename (module.js:320:11)
When I type in express --version I get a return statement of 2.3.3. I used npm to install express. I had to manually make npm using these instructions:
git clone http://github.com/isaacs/npm.git
cd npm
sudo make install
The error is Error: Cannot find module 'express'.
Do I need to do something after installing npm and express in order to make express see the modules created by npm?
My node is version: 0.4.6
My express is version: 2.3.3
My npm is version: 1.0.6
Express is installed globally. I used the -g flag to install it.
Edit: When I try "node -e require.paths" I get:
[ '/home/user/.node_modules',
'/home/user/.node_libraries',
'/usr/local/lib/node' ]
So, node isn't detecting the npm installation. How do I get node to detect the npm installation?
Install express
npm install -g express
Create a new app
express your_app
cd into app directory
cd your_app
use npm link to resolve modules
npm link express
Use local installs for require(), and global installs for command-line apps.
If you need both, use the npm link command.
On Ubuntu 12.04 you have to add the export NODE_PATH=/usr/local/lib/node_modules to your /.bashrc to use globally installed modules.
It appears that while npm had been updated to install global modules into /usr/local/lib/node_modules, Node's own require.paths does not yet reflect this change.
There are two reasonable solutions:
Add the following code to the top of your application:
require.paths.push('/usr/local/lib/node_modules');
Pro: non-invasive, easy to add
Con: requires discipline, future versions of node will restrict access to require.paths
As root, execute:
ln -s /usr/local/lib/node_modules /usr/local/lib/node
Pro: reasonably non-invasive
Con: requires root, modifies linux fs, might not survive system updates
I had the same problem. This worked for me though:
Seems like npm (now?) installs node modules to /usr/local/lib/node_modules/ and not /usr/local/lib/node/
What I did was simply to copy everything from node_modules to node: sudo cp -r /usr/local/lib/node_modules/* usr/local/lib/node/ and now it seems to be working for me.
Hope this helps you :-)
What about NODE_PATH=/usr/local/lib/node_modules in .bashrc or .bash_profile? I think it's the real correct way.
Set NODE_PATH=NODE_HOME\node_modules.
I'm using windows 7 and it works fine.
It may happen, if you're using windows, that the environment variable NODE_PATH is not set, and thus when you execute node fileName.js it won't find the libraries.
Check for the variable on your console, and if not present, create it. Give it the NODE_HOME\node_modules value, where NODE_HOME is your node install dir. This path is where npm install puts every module upon downloading.
require.paths is removed, use the NODE_PATH environment variable instead.
It looks like the easiest way to do this is to run npm install from your app's folder. This tells npm to hook everything up.
It's the last instruction after express <appname>:
...
dont forget to install dependencies:
$ cd <appname> && npm install
Finally with Linux a good way to do is to use the command : sudo apt-get install node-express
But with express 4 we must use express-generator to make app skeleton, install it with 'npm install express-generator -g', and then run 'express myapp' command.
see also install express
for mac users
cd /usr/local/lib/node
sudo ln -s ../node_modules/* ./$1
I installed gulp and when I ran this gulp command in the command line I got a gulp: command not found error. It appeared that it installed gulp in my local folder that is /home/YOURUSERNAME/.node/lib/node_modules and not in the global npm folder.
You can check npm root folder by running this command: npm root -g, which was returning my personal directory /home/YOURUSERNAME/.node/lib/node_modules and not the expected /usr/local/lib/node_modules.
You can fix this by running npm config set prefix /usr/local command.
For all problems with express with a mac computer:
The solution is:
chown to your user the .npm folder :
sudo chown -R Webmaste /Users/webmaste/.npm/
At your test folder or your folder:
sudo npm install -g express#2.5.8
Invoke express from your actual location:
/usr/local/share/npm/bin/express
sudo cd . && npm install
Finally:
node app
the final message in the console should look like this:
Express server listening on port 3000 in development mode

Categories

Resources