Node.Js and Socket.IO application on Heroku - javascript

I am having this error message when I try to deploy my application on Heroku. Any suggestions? I can easily deploy my app on localhost but it doesn't work on Heroku.
My Package.JSON is:
{
"name":"tryout",
"version":"0.0.1",
"private":true,
"scripts":{
"start":"node app"
},
"dependencies":{
"express":"3.0.0rc3",
"jade":"*",
"passport":">= 0.1.11",
"passport-local":">= 0.1.3",
"underscore":">= 1.3.3",
"socket.io":">= 0.9.6",
"node-uuid":">= 1.3.3",
"mongoose":">= 3.0.2",
"bcrypt":">= 0.7.1"
},
"engines": {
"node": "0.8.x",
"npm": "1.1.x"
}
}
PS: I don't use hiredis at all.
Input command is: git push heroku master
Counting objects: 1731, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (1541/1541), done.
Writing objects: 100% (1731/1731), 7.42 MiB | 400 KiB/s, done.
Total 1731 (delta 192), reused 0 (delta 0)
-----> Removing .DS_Store files
-----> Node.js app detected
-----> Resolving engine versions
Using Node.js version: 0.8.14
Using npm version: 1.1.65
-----> Fetching Node.js binaries
-----> Vendoring node into slug
-----> Installing dependencies with npm
npm WARN package.json socket-app#0.0.1 No README.md file found!
npm WARN package.json jade#0.27.2 No README.md file found!
> hiredis#0.1.14 preinstall /tmp/build_37k5gxae7u8vc/node_modules/hiredis
> make || gmake
cd deps/hiredis && make static
make[1]: Entering directory `/tmp/build_37k5gxae7u8vc/node_modules/hiredis/deps/hiredis'
make[1]: Nothing to be done for `static'.
make[1]: Leaving directory `/tmp/build_37k5gxae7u8vc/node_modules/hiredis/deps/hiredis'
node-waf configure build
Setting srcdir to : /tmp/build_37k5gxae7u8vc/node_modules/hiredis
Setting blddir to : /tmp/build_37k5gxae7u8vc/node_modules/hiredis/build
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for node path : not found
Checking for node prefix : ok /tmp/node-node-jj2B
'configure' finished successfully (0.056s)
Waf: Entering directory `/Users/USERNAME/Developer/Sites/bla/node_modules/hiredis/build'
Waf: Leaving directory `/Users/USERNAME/Developer/Sites/bla/node_modules/hiredis/build'
Traceback (most recent call last):
File "/tmp/node-node-jj2B/bin/node-waf", line 16, in <module>
Scripting.prepare(t, os.getcwd(), VERSION, wafdir)
File "/tmp/node-node-jj2B/bin/../lib/node/wafadmin/Scripting.py", line 145, in prepare
prepare_impl(t, cwd, ver, wafdir)
File "/tmp/node-node-jj2B/bin/../lib/node/wafadmin/Scripting.py", line 135, in prepare_impl
main()
File "/tmp/node-node-jj2B/bin/../lib/node/wafadmin/Scripting.py", line 188, in main
fun(ctx)
File "/tmp/node-node-jj2B/bin/../lib/node/wafadmin/Scripting.py", line 386, in build
return build_impl(bld)
File "/tmp/node-node-jj2B/bin/../lib/node/wafadmin/Scripting.py", line 405, in build_impl
bld.compile()
File "/tmp/node-node-jj2B/bin/../lib/node/wafadmin/Build.py", line 268, in compile
os.chdir(self.bldnode.abspath())
OSError: [Errno 2] No such file or directory: '/Users/USERNAME/Developer/Sites/bla/node_modules/hiredis/build'
make: *** [all] Error 1
sh: gmake: not found
npm ERR! hiredis#0.1.14 preinstall: `make || gmake`
npm ERR! `sh "-c" "make || gmake"` failed with 127
npm ERR!
npm ERR! Failed at the hiredis#0.1.14 preinstall script.
npm ERR! This is most likely a problem with the hiredis package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! make || gmake
npm ERR! You can get their info via:
npm ERR! npm owner ls hiredis
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 2.6.32-347-ec2
npm ERR! command "/tmp/node-node-jj2B/bin/node" "/tmp/node-npm-nN2P/cli.js" "install" "--production"
npm ERR! cwd /tmp/build_37k5gxae7u8vc
npm ERR! node -v v0.8.14
npm ERR! npm -v 1.1.65
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /tmp/build_37k5gxae7u8vc/npm-debug.log
npm ERR! not ok code 0
! Failed to install --production dependencies with npm
! Heroku push rejected, failed to compile Node.js app
To git#heroku.com:arcane-sea-8207.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:arcane-sea-8207.git'

It seems hiredis is indirectly needed by express, which you have a release candidate version, which might be the problem. Try to change express to:
"express":"3.x"
Also, make sure you don't commit the node_modules directory to your git repo. Add it to .gitignore!

Related

Unable to install `#nuxtjs/sentry` in Node 16.14 docker container. Permission errors

I'm trying to install #nuxtjs/sentry using npm install #nuxtjs/sentry. These are the errors I'm getting.
npm ERR! code 1
npm ERR! path /app/node_modules/#sentry/cli
npm ERR! command failed
npm ERR! command sh -c node ./scripts/install.js
npm ERR! info sentry-cli Downloading from https://downloads.sentry-cdn.com/sentry-cli/1.74.4/sentry-cli-Linux-x86_64
npm ERR! Error: EACCES: permission denied, mkdir '/root/.npm/sentry-cli'
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-06-24T08_02_47_860Z-debug-0.log
exited with code 1
You probably need to use unsafe-perm
either:
add a file called .npmrc in your project's root directory and put this in it
unsafe-perm=true
OR
just use this command before installing (I didn't confirm this)
sudo npm config set unsafe-perm true
Basically npm would download the packages as root but then try to install the binaries as a local user without root permissions so it wouldn't have access to the directory where the binaries were downloaded at.
You just better double check the packages that you install to make sure they are trustworthy, otherwise it's safe to do so
Note: I only tried it on node 14, didn't test it on node 16

Heroku Build Fail [sh: 1: react-scripts: Permission denied]

----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version 12.x...
Downloading and installing node 12.13.0...
Using default npm version: 6.12.0
-----> Installing dependencies
Prebuild detected (node_modules already exists)
Rebuilding any native modules
> nodemon#1.19.3 postinstall /tmp/build_33db88ab97938128199a401d17366aac/node_modules/nodemon
> node bin/postinstall || exit 0
Love nodemon? You can now support the project via the open collective:
> https://opencollective.com/nodemon/donate
//REMOVED INSTALLATION TEXT HERE DUE TO CHAR LIMIT
-----> Build
Running heroku-postbuild
> website_setup#1.0.0 heroku-postbuild /tmp/build_33db88ab97938128199a401d17366aac
> NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
audited 905041 packages in 14.447s
found 1 moderate severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
> client#0.1.0 build /tmp/build_33db88ab97938128199a401d17366aac/client
> react-scripts build
sh: 1: react-scripts: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! client#0.1.0 build: `react-scripts build`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the client#0.1.0 build 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/npmcache.1egfD/_logs/2019-11-08T01_04_59_454Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! website_setup#1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the website_setup#1.0.0 heroku-postbuild 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/npmcache.1egfD/_logs/2019-11-08T01_04_59_470Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
Some possible problems:
- node_modules checked into source control
https://blog.heroku.com/node-habits-2016#9-only-git-the-important-bits
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
Synopsis:
I recently finished MERN stack course and went to go push my build to Heroku but encountered the error above. I first thought it was a visual studio permissions error so I ran vs code with elevated privileges. This, however, did not work.
I've tried and had no success with:
Adding a nodejs script build package to my deployment
Modifying my package.json to incorporate engine which selects the version of node.js to run
Adding .js extensions to the end of the server in the scripts section thinking there may be a simple issue with that
Double checking that my local instance works properly (it does)
Promptly throwing my computer out my window (feels pretty good, but still not working)
Refer to this link to see how to check your file for the correct permissions and how to set them ( Updating file permissions with git-bash on Windows 7 )
sh: 1: react-scripts: Permission denied
So this is a permission issue. Go to the correct path that contains a react-scripts and do a chmod +x react-scripts will solve this issue.
I took a look at you GitHub repo and it seems to be a simple typo in your .gitignore file :
node_module/
config/default.json
And this should be :
node_modules/
config/default.json
Notice the name of node_modules folder ,so a quick fix would be to edit you .gitignore file and put the wright name , then run the following :
git rm -r --cached node_modules
delete node_modules in root directory as well in client/
git commit -am 'ignore node_modules'
And finally push your changes , this should fix the error .
check your package.json => React-script-->
step = 1==> "react-scripts": "(change_currend_version)"
Ex: "react-scripts": "1.0.1" change ==>"react-scripts": "3.4.3"
step = 2==> install ==> npm i
step = 3 ==> npm start

Deploy angular 6 in Azure

I am trying to deploy an example app on the azure portal and am encountering some difficulties.
At first I'm just testing, so I've created an angular app with just ng new poc-pwa-angular-v2. After that I went up to a Bitbucket repository.
In Azure I created a web application and in the deployment options I connected on bitbucket and set my master branch.
I tried to generate the scripts with kudu (deploy.cmd and .deployment), but I got an error on the first deploy.
Can anyone give a tip?
Look at my log.
Command: deploy.cmd
Handling node.js deployment.
Creating app_offline.htm
KuduSync.NET from: 'D:\home\site\repository' to: 'D:\home\site\wwwroot'
Copying file: 'package.json'
Deleting app_offline.htm
Invalid start-up command "ng serve" in package.json. Please use the format "node <script relative path>".
Looking for app.js/server.js under site root.
Missing server.js/app.js files, web.config is not generated
The package.json file does not specify node.js engine version constraints.
The node.js application will run with the default node.js version 10.6.0.
Selected npm version 6.1.0
> poc-pwa-angular-v2#0.0.0 postinstall D:\home\site\wwwroot
> npm run build
> poc-pwa-angular-v2#0.0.0 build D:\home\site\wwwroot
> ng build
'ng' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! poc-pwa-angular-v2#0.0.0 build: `ng build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the poc-pwa-angular-v2#0.0.0 build 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! D:\local\AppData\npm-cache\_logs\2018-11-13T22_16_35_989Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! poc-pwa-angular-v2#0.0.0 postinstall: `npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the poc-pwa-angular-v2#0.0.0 postinstall 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:
Failed exitCode=1, command="D:\Program Files (x86)\nodejs\10.6.0\node.exe" "D:\Program Files (x86)\npm\6.1.0\node_modules\npm\bin\npm-cli.js" install --production
npm ERR! D:\local\AppData\npm-cache\_logs\2018-11-13T22_16_36_053Z-debug.log
An error has occurred during web site deployment.
Invalid start-up command "ng serve" in package.json. Please use the format "node <script relative path>".\r\nMissing server.js/app.js files, web.config is not generated\r\n'ng' is not recognized as an internal or external command,\r\noperable program or batch file.\r\nnpm ERR! code ELIFECYCLE\r\nnpm ERR! errno 1\r\nnpm ERR! poc-pwa-angular-v2#0.0.0 build: `ng build`\r\nnpm ERR! Exit status 1\r\nnpm ERR! \r\nnpm ERR! Failed at the poc-pwa-angular-v2#0.0.0 build script.\r\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\r\n\r\nnpm ERR! A complete log of this run can be found in:\r\nnpm ERR! D:\local\AppData\npm-cache\_logs\2018-11-13T22_16_35_989Z-debug.log\r\nnpm ERR! code ELIFECYCLE\r\nnpm ERR! errno 1\r\nnpm ERR! poc-pwa-angular-v2#0.0.0 postinstall: `npm run build`\r\nnpm ERR! Exit status 1\r\nnpm ERR! \r\nnpm ERR! Failed at the poc-pwa-angular-v2#0.0.0 postinstall script.\r\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\r\n\r\nnpm ERR! A complete log of this run can be found in:\r\nnpm ERR! D:\local\AppData\npm-cache\_logs\2018-11-13T22_16_36_053Z-debug.log\r\nD:\Program Files (x86)\SiteExtensions\Kudu\78.11022.3613\bin\Scripts\starter.cmd deploy.cmd
The issue is that on Azure Angular cli is not installed.
You will need to do ng build locally(or as part of your build and release pipe line. You can also use Azure DevOps builds for that where you have 240 build minutes for free) and upload it to (just options):
Azure App service.
Upload it to blob storage and use Azure functions proxy to serve your files.
If you need server side rendering then you will need to upload it as an NodeJs app or part of .net app
Thanks for the time of yours, in this case I removed the package.json script block and went up again and it worked.
...
"version": "0.0.0",
"scripts": {
},
...

cannot install npm? problems generating application

ok ... first time I'm trying my hand at node.js.
installed it a while back, and not sure how i installed it.
last night, decided to tackle a tutorial regarding node.js and express.
checked my version of node which is v0.8.14 and npm which is 1.1.65. (I'm on Mac, 10.6.8 version)
but did this anyway
npm install -g express
seemed to go ok ... but whenever I tried to generate a new application via
express new ProjectName
I got this:
-bash: express: command not found
Decided to try
sudo npm install express -g
which again seemed to go well ... but again, the express new ProjectName got the same statement.
tried again:
npm install -g express
got a lot of errors unlike the first time.
npm WARN package.json application-name#0.0.1 No README.md file found!
AA-s-MacBook-Pro:express_node aa$ express new HotPie
-bash: express: command not found
AA-s-MacBook-Pro:express_node aa$ npm cache clean
AA-s-MacBook-Pro:express_node aa$ npm install -g express
npm http GET https://registry.npmjs.org/express
npm http 200 https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/express/-/express-3.0.6.tgz
npm http 200 https://registry.npmjs.org/express/-/express-3.0.6.tgz
npm ERR! error rolling back Error: EPERM, chmod '/usr/local/share/npm/bin/express'
npm ERR! error rolling back express#3.0.6 { [Error: EPERM, chmod '/usr/local/share /npm/bin/express']
npm ERR! error rolling back errno: 50,
npm ERR! error rolling back code: 'EPERM',
npm ERR! error rolling back path: '/usr/local/share/npm/bin/express' }
npm ERR! Error: EPERM, chmod '/usr/local/share/npm/bin/express'
npm ERR! { [Error: EPERM, chmod '/usr/local/share/npm/bin/express']
npm ERR! errno: 50,
npm ERR! code: 'EPERM',
npm ERR! path: '/usr/local/share/npm/bin/express' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 10.8.0
npm ERR! command "/usr/local/Cellar/node/0.8.14/bin/node" "/usr/local/bin/npm" "install" "-g" "express"
npm ERR! cwd /Users/aa/Documents/express_node
npm ERR! node -v v0.8.14
npm ERR! npm -v 1.1.65
npm ERR! path /usr/local/share/npm/bin/express
npm ERR! code EPERM
npm ERR! errno 50
npm ERR! stack Error: EPERM, chmod '/usr/local/share/npm/bin/express'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/aa/Documents/express_node/npm-debug.log
npm ERR! not ok code 0
and so it went on and on: errors ... or no errors. I'm at total loss. and online literature on fixing this problem seems rather sparse.
advice, please?
oh, also saw this somewhere online: (whatever it means)
/usr/local/share/npm/bin/express
which resulted in this:
destination is not empty, continue?
destination is not empty, continue? (yes or no) yes
create : .
create : ./package.json
create : ./app.js
create : ./public/javascripts
create : ./public/images
create : ./public/stylesheets
create : ./public/stylesheets/style.css
create : ./routes
create : ./routes/index.js
create : ./routes/user.js
create : ./views
create : ./views/layout.jade
create : ./views/index.jade
create : ./public
install dependencies:
$ cd . && npm install
run the app:
$ node app
so ... ??? any advice would be appreciated! (please also let me know if I left any pertinent information required)
Sounds like you need to edit your path variable.
Edit your ~/.bash_profile. Add this export somewhere.
export PATH=/usr/local/bin:$PATH:/usr/local/share/npm/bin
What's happening is that node isn't setting up its PATH correctly. I've had this happen to me before. Its something they should fix.
You may not have a .bash_profile. In *nix systems, there are a few different files you can place in your home directory to add environment variables and such.
bash_profile is the one I prefer, so in the terminal cd to ~ and touch .bash_profile.
Then edit it via nano .bash_profile or whatever editor you like.
(In nano, control-o to save, control-x to exit.)
When you've added it, do: source .bash_profile
Then try which express and see if it shows the path.

Error trying to install npm for Node.js

I'm having a stab at learning Node.js and I'm having a few issues when installing NPM (Node Package Manager). I'm pretty sure it's either a permissions thing or folder thing... please note that I've just purchased a Mac (I've used Windows all my life) and I'm pretty unfamiliar with the Mac terminal.
Okay, I went to use the one line install for NPM: curl http://npmjs.org/install.sh | sh and I got an error...
All clean!
! [ -d .git ] || git submodule update --init --recursive
node cli.js rm npm -g -f
node cli.js install -g -f
npm ERR! Could not create /usr/local/lib/node_modules/___npm.npm
npm ERR! error installing npm#1.0.94 Error: EACCESS, Undefined error: 0 '/usr/local/lib/node_modules'
npm ERR! Error: EACCESS, Undefined error: 0 '/usr/local/lib/node_modules'
npm ERR! Report this *entire* log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR!
npm ERR! System Darwin 11.0.0
npm ERR! command "node" "/private/var/folders/z2/f05c8hx105g79drh6r7hr01w0000gn/T/npm.1219/package/cli.js" "install" "-g" "-f"
npm ERR! cwd /private/var/folders/z2/f05c8hx105g79drh6r7hr01w0000gn/T/npm.1219/package
npm ERR! node -v v0.5.9-pre
npm ERR! npm -v 1.0.94
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCESS
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /private/var/folders/z2/f05c8hx105g79drh6r7hr01w0000gn/T/npm.1219/package/npm-debug.log
npm not ok
make: *** [install] Error 1
npm ERR! Could not create /usr/local/lib/node_modules/___npm.npm
npm ERR! error installing npm#1.0.94 Error: EACCESS, Undefined error: 0 '/usr/local/lib/node_modules'
npm ERR! Error: EACCESS, Undefined error: 0 '/usr/local/lib/node_modules'
npm ERR! Report this *entire* log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR!
npm ERR! System Darwin 11.0.0
npm ERR! command "/usr/local/bin/node" "/private/var/folders/z2/f05c8hx105g79drh6r7hr01w0000gn/T/npm.1219/package/cli.js" "install" "-gf"
npm ERR! cwd /private/var/folders/z2/f05c8hx105g79drh6r7hr01w0000gn/T/npm.1219/package
npm ERR! node -v v0.5.9-pre
npm ERR! npm -v 1.0.94
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCESS
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /private/var/folders/z2/f05c8hx105g79drh6r7hr01w0000gn/T/npm.1219/package/npm-debug.log
npm not ok
It failed
there's obviously a folder issue here, perhaps I'm installing in the wrong place, my node folder is at Users/Mike/node, when I try and find out my node path variable using NODE_PATH I get the following error:
Michaels-MacBook-Pro:~ Mike$ node node/NODE_PATH
node.js:203
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module '/Users/Mike/node/NODE_PATH'
at Function._resolveFilename (module.js:334:11)
at Function._load (module.js:279:25)
at Array.<anonymous> (module.js:470:10)
at EventEmitter._tickCallback (node.js:195:26)
Can someone please tell me what I'm doing wrong? Do I need to add the node path like such:
$ export PATH=/path/to/node/0.n.y/bin:${PATH}
$ curl http://npmjs.org/install.sh | sh
Or am I confusing myself?
The permissions on /usr/local require you to use sudo to install NPM, or change your permissions. Of these three, I recommend the third option.
Option #1: Use sudo
(Note that the the creator of NPM advises against using this method)
curl http://npmjs.org/install.sh | sudo sh
Option #2: Change permissions
sudo chmod g+rwx /usr/local
sudo chgrp admin /usr/local
Option #3: Use Homebrew
I recommend installing Homebrew to manage installing *nix tools on OS X (I'd stay away from MacPorts & Fink). Installing Homebrew will set the permissions for /usr/local so you can write to it without sudo. You can then install Node via Homebrew, and then install NPM normally:
brew install node --without-npm
curl http://npmjs.org/install.sh | sh
Use curl http://npmjs.org/install.sh | sudo sh.
Edit: You're using node -v v0.5.9-pre, which is very unstable. Use 0.4.12, the latest stable version.
if you are using windows , it takes some steps , 1) create a file called package.json
{
"name": "hello"
, "version": "0.0.1"
, "dependencies": {
"express": "*"
}
}
where hello is the name of the package and * means the latest version of your dependency
2) code to you project directory and run the following command
npm install
As update for the method #3 on OSX the correct command now is:
brew install node --without-npm
curl https://www.npmjs.org/install.sh | sh
Option #4:
Install node local to the user that needs it.
I should clarify for my purposes I needed npm to install appium on an OSX server running Bamboo for our integrated testing. I only had macports available and rather than installing homebrew to manage just the one package I decided to build it from source and install it local to the bamboo user. Which allowed us to run appium as the bamboo user and made it possible to run our appium tests on Bamboo as a not very privileged user.
This guide from Tom Novelli goes over how to do it. The basic gist is:
# Make the dir to hold the installation of node
cd
mkdir ./local
mkdir sources
# Tell npm about your new non-default directories
vi .npmrc
cd sources
# Get node and do the typical source install procedure
wget http://nodejs.org/dist/v0.10.29/node-v0.10.29.tar.gz
tar xf node-v0.10.29.tar.gz
cd node-v8.10.29/
# Important part is the --prefix
./configure --prefix=~/.local
make
make install
# Make a link so node doesn't get confused
cd
ln -s .local/lib/node_modules .node_modules
# Edit PATH to include ~/.local
vi .bashrc
.npmrc
root = /home/YOUR-USERNAME/.local/lib/node_modules
binroot = /home/YOUR-USERNAME/.local/bin
manroot = /home/YOUR-USERNAME/.local/share/man
.bashrc OR .profile OR whereever you like setting your path
export PATH=$HOME/.local/bin:$PATH
Useful Links
The .npmrc man page useful.
And just in case here's a link to node source.

Categories