i am a beginner in AWS, and I encountered this problem very early on.
I created an EB environment and a code-pipeline in AWS. So whenever I push something to the repository, the app gets deployed. So for now I just have a "Hello world" node.js app, but I want to install the sharp npm dependency for later on. When I put the dependency in the package.json file and push it to the repo, a get the following error:
error on deployment.
I have done a lot of googling, and I think it has something to do with setting permissions to install the sharp dependency. However, none of the solutions I found have worked so far.
If anything is unclear, I apologize and let me know :).
Please reference my "workaround" solution provided in the following GitHub Issue (Fails to install on AWS ElasticBeanstalk with node16 #3221) for a full explanation.
Solution:
Create the following Platform Hooks paths in the root directory of your application bundle.
.platform/hooks/prebuild
.platform/confighooks/prebuild
Create the following bash script (00_npm_install.sh) with execute permissions (chmod +x).
#!/bin/bash
cd /var/app/staging
sudo -u webapp npm install sharp
Validate the Application Bundle Structure.
Ex. Sample project structure:
~/my-app/
├── app.js
├── index.html
├── .npmrc_bkp
├── package.json
├── package-lock.json
├── .platform
│ ├── confighooks
│ │ └── prebuild
│ │ └── 00_npm_install.sh
│ └── hooks
│ └── prebuild
│ └── 00_npm_install.sh
└── Procfile
Deploy the Application!
Hope it helps!
I wanted to install the latest version of socket.io, and the latest ver seems to be 1.45.socket.io download
To do this, I just type the following command.
npm install socket.io
However, when I checked installed modules in my laptop, socket.io's version did not change as can be seen below.
YANAGISAWAYUMA-no-MacBook-Pro:~ yanagisawa_yuma$ npm list --depth=0
yanagisawa_yuma#0.0.0 /Users/yanagisawa_yuma
├── ar-drone#0.3.3 extraneous (git://github.com/felixge/node-ar-drone.git#228bd4573e765bed3861f259ce7e66fcace15f43)
├── express#4.9.0
├── gulp#3.9.0
├── node#0.0.0
├── node-osc#1.1.0 extraneous
├── node-static#0.7.3
├── socket.io#1.1.0
└── static#2.0.0
What am I missing?
Instead of simply npm install socket.io,
try npm install socket.io#version
js on my windows 7 machine, i have executed the below commands from
C:\node> npm install -g express -generator
and also C:\node> npm install -g express -generator#4, and also the npm link express
for the above commands, i got the below messages.
express#4.10.7 C:\Users\user1\AppData\Roaming\npm\node_modules\express
├── methods#1.1.1
├── finalhandler#0.3.3
├── cookie-signature#1.0.5
├── serve-static#1.7.2
├── merge-descriptors#0.0.2
├── utils-merge#1.0.0
├── range-parser#1.0.2
├── media-typer#0.3.0
├── cookie#0.1.2
├── content-disposition#0.5.0
├── parseurl#1.3.0
├── vary#1.0.0
├── escape-html#1.0.1
├── fresh#0.2.4
├── path-to-regexp#0.1.3
├── depd#1.0.0
├── qs#2.3.3
├── on-finished#2.2.0 (ee-first#1.1.0)
├── etag#1.5.1 (crc#3.2.1)
├── debug#2.1.1 (ms#0.6.2)
├── type-is#1.5.5 (mime-types#2.0.7)
├── accepts#1.1.4 (negotiator#0.4.9, mime-types#2.0.7)
├── send#0.10.1 (destroy#1.0.3, ms#0.6.2, mime#1.2.11, on-finished#2.1.1)
└── proxy-addr#1.0.4 (forwarded#0.1.0, ipaddr.js#0.1.5)
and with npm link express:
C:\node\node_modules\express -> C:\Users\user1\AppData\Roaming\npm\node_modul
es\express
but still when i execute the express nodetest1 at C:/node> i am getting the express is not recognized error.
anyone know any pointers would be helpful.
You have a space between express and -generator above... if this was copy-pasted, maybe you missed it... it's supposed to be express-generator as a single unit.
Make certain that %USERPROFILE%\AppData\Roaming\npm both exists and is in your PATH environment variable... If it isn't there, you will have to open a new prompt after adding it. Some versions of node's installer don't always create or add it correctly.
If you are using [nvm for windows] you will need to ensure that C:\Program Files\nodejs is in your path (the installer should work correctly), you'll need to run nvm via command prompt Run as Administrator. This is because nvm uses symbolic links from the global install path to a specific version under your profile to run against.
I've been using nvm for windows for a few months now (switching from 0.10.x and 0.11.x versions) and it's been a bit easier to work with.
Make sure you are runing the command promt as System Administrator "This is very important", then do npm install -g express after that chang to the directory where you want to create your app and you are good to go. NB if you are using express 4 then install it via npm install -g express-generator#4
I installed express, and it worked just fine:
...
npm http 200 https://registry.npmjs.org/send/-/send-0.1.4.tgz
npm http GET https://registry.npmjs.org/fresh/0.2.0
npm http GET https://registry.npmjs.org/range-parser/0.0.4
npm http 304 https://registry.npmjs.org/fresh/0.2.0
npm http GET https://registry.npmjs.org/fresh/-/fresh-0.2.0.tgz
npm http 304 https://registry.npmjs.org/range-parser/0.0.4
npm http GET https://registry.npmjs.org/range-parser/-/range-parser-0.0.4.tgz
npm http 200 https://registry.npmjs.org/fresh/-/fresh-0.2.0.tgz
npm http 200 https://registry.npmjs.org/range-parser/-/range-parser-0.0.4.tgz
express#4.0.0 /usr/local/lib/node_modules/express
├── methods#0.1.0
├── parseurl#1.0.1
├── merge-descriptors#0.0.2
├── utils-merge#1.0.0
├── escape-html#1.0.1
├── debug#0.8.0
├── cookie-signature#1.0.3
├── range-parser#1.0.0
├── fresh#0.2.2
├── qs#0.6.6
├── buffer-crc32#0.2.1
├── cookie#0.1.0
├── path-to-regexp#0.1.2
├── type-is#1.0.0 (mime#1.2.11)
├── send#0.2.0 (mime#1.2.11)
├── accepts#1.0.0 (mime#1.2.11, negotiator#0.3.0)
└── serve-static#1.0.1 (send#0.1.4)
But then i do:
express testapp
-bash: express: command not found
It's as if express is not installed. What's up with that?
Just FYI, i have OSX if that makes any difference?
The new version of Express (4.0) does not itself have a bin folder. You have to install express-generator to get the setup functionality.
Express 4.0 made significant changes. Specifically, moving middlewares and helpers into external modules.
If you need to get something up and running right away, you should install Express 3 and then learn how to get Express 4 running when you have more time.
First, make sure you have ./node_modules/.bin in your $PATH. Then...
npm install "express#3.x"
express
Or if you have time to learn the differences in Express 4 then you can get up and running by installing express-generator.
npm install express-generator
express
IMPORTANT: make sure you have ./node_modules/.bin in your shell $PATH variable. Executable files in Node modules are linked in the ./node_modules/.bin directory. Having that in your path makes it easy to run those executables without typing the whole path and without adding them globally. Adding them globally is a bad idea if you work with multiple projects and need to maintain backwards compatibility with old projects.
TIP: You can find the list of Express middlewares and helpers on Github.
Here is how I got my express app to work. I first ran
npm install -g express-generator
Then I created my app with
express app_name
Where app_name is obviously the name of your app.
Then I installed the dependancies.
cd app_name && npm install
Then to run the app I did
DEBUG=app_name ./bin/www
The prompts were generated by the system and you can copy and paste them. Then you visit
http://localhost:3000/
Here is my app working locally
I'm trying to build a github jquery-ui library using grunt, but after running npm install I still can't run the command according to the readme file. It just gives No command 'grunt' found:
james#ubuntu:~/Documents/projects/ad2/lib/jquery-ui$ grunt build
No command 'grunt' found, did you mean:
Command 'grun' from package 'grun' (universe)
grunt: command not found
james#ubuntu:~/Documents/projects/ad2/lib/jquery-ui$ npm ls
jquery-ui#1.9.0pre /home/james/Documents/projects/ad2/lib/jquery-ui
├─┬ grunt#0.3.9
│ ├── async#0.1.18
│ ├── colors#0.6.0-1
│ ├─┬ connect#1.8.7
│ │ ├── formidable#1.0.9
│ │ ├── mime#1.2.5
│ │ └── qs#0.5.0
│ ├── dateformat#1.0.2-1.2.3
│ ├─┬ glob-whatev#0.1.6
│ │ └─┬ minimatch#0.2.4
│ │ └── lru-cache#1.0.6
│ ├─┬ gzip-js#0.3.1
│ │ ├── crc32#0.2.2
│ │ └── deflate-js#0.2.2
│ ├── hooker#0.2.3
│ ├─┬ jshint#0.5.9
│ │ ├── argsparser#0.0.6
│ │ └─┬ minimatch#0.2.4
│ │ └── lru-cache#1.0.6
│ ├─┬ nodeunit#0.6.4
│ │ ├── tap-assert#0.0.10
│ │ └─┬ tap-producer#0.0.1
│ │ ├── inherits#1.0.0
│ │ ├── tap-results#0.0.2
│ │ └── yamlish#0.0.5
│ ├─┬ nopt#1.0.10
│ │ └── abbrev#1.0.3
│ ├─┬ prompt#0.1.12
│ │ ├── pkginfo#0.2.3
│ │ └─┬ winston#0.5.11
│ │ ├── eyes#0.1.7
│ │ ├─┬ loggly#0.3.11
│ │ │ └── timespan#2.2.0
│ │ └── stack-trace#0.0.6
│ ├── semver#1.0.13
│ ├─┬ temporary#0.0.2
│ │ └── package#1.0.0
│ ├── uglify-js#1.0.7
│ ├── underscore#1.2.4
│ └── underscore.string#2.1.1
├── grunt-compare-size#0.1.4
├─┬ grunt-css#0.2.0
│ ├── csslint#0.9.8
│ └── sqwish#0.2.0
├── grunt-html#0.1.1
├── request#2.9.153
├─┬ rimraf#2.0.1
│ └── graceful-fs#1.1.8
└─┬ testswarm#0.2.2
└── request#2.9.202
I'm confused, what am I missing please?
The command line tools are not included with the latest version of Grunt (0.4 at time of writing) instead you need to install them separately.
This is a good idea because it means you can have different versions of Grunt running on different projects but still use the nice concise grunt command to run them.
So first install the grunt cli tools globally:
npm install -g grunt-cli
(or possibly sudo npm install -g grunt-cli ).
You can establish that's working by typing grunt --version
Now you can install the current version of Grunt local to your project. So from your project's location...
npm install grunt --save-dev
The save-dev switch isn't strictly necessary but is a good idea because it will mark grunt in its package.json devDependencies section as a development only module.
Add /usr/local/share/npm/bin/ to your $PATH
If you did have installed Grunt package by running npm install -g grunt and it still say's No command 'grunt' found or grunt: command not found, a quick and dirty way to get this working is linking node binaries to your $PATH manually.
On MacOSX/Linux you can add this line to your ~/.bash_profile or ~/.bashrc file.
PATH=$PATH:/usr/local/Cellar/node/HEAD/bin # Add NPM binaries
You probably should replace /usr/local/Cellar/node/HEAD/bin by the path where your node binaries could be found.
If this is quick and dirty to me, it's because everything should work without doing this, but for an unknown reason, a link seem broken. As nobody on IRC could tell me why this happened, I found my own way to make it (grunt) work.
PS: This should help you make grunt works, this answer is not jquery-ui related.
Update 02/2013 : You should take a look at #tom-p's answer which explains better what is going on. Tom gives us the real solution instead of hacking your bashrc file : both should work, but you should try installing grunt-cli first.
In my case, i need modify the file /usr/local/bin/grunt in line 1 ( don't make this ):
#!/usr/bin/env node //remove this line
#!/usr/bin/env nodejs // and put this line to run with nodejs
Edited:
To avoid problems, I created a link with the name of "node" because many other programs still use "node" command.
sudo ln -s /usr/bin/nodejs /usr/sbin/node
There is one more way to run grunt on windows, without adding anything globally. This is a case when you don't have to do anything with %PATH%
if you have grunt and grunt-cli installed (without -g switch).
Either by:
npm install grunt-cli
npm install grunt#0.4.5
Or by having that in your packages.json file like:
"devDependencies": {
"grunt-cli": "^1.2.0",
"grunt": "^0.4.5",
You can call grunt from your local installation by:
node node_modules\grunt-cli\bin\grunt --version
This is a solution for those who for some reasons don't want to or can't play with PATH, or have something else messing it all the time, for instance on a build agent.
Edit:
Added versions as the grunt-cli works with grunt > 0.3
On WIN7 I had to manually add the path to the npm folder (which contains the elusive 'grunt' file) to the Windows PATH environmental variable.
In my case that was C:\Users\mhaagsma\AppData\Roaming\npm
Hello I had this problem on mac, and what I did was
installed globally and prefix with global path
sudo npm install grunt -g --prefix=/usr/local
now
$ which grunt
should out put
/usr/local/bin/grunt
Cheers
The right way to install grunt is by running this command:
npm install grunt -g
(Prepend "sudo" to the command above if you get a EACCESS error message)
-g will make npm install the package globally, so you will be able to use it whenever you want in your current machine.
Instala grunt de manera global: sudo npm install -g grunt-cli --unsafe-perm=true --allow-root
Try to run grunt.
If you have this message:
Warning:
You need to have Ruby and Sass installed and in your PATH for this task to work.
More info: https://github.com/gruntjs/grunt-contrib-sass
Used --force, continuing.
3.1. Check that you have ruby installed (mac, you should have it): ruby -v
Sometimes you have to npm install package_name -g for it to work.
Other solution is to remove the ubuntu bundler in my case i used:
sudo apt-get remove ruby-bundler
That worked for me.
On Windows, part of the mystery appears to be where npm installs the Grunt.cmd file. While on my Linux box, I just had to run sudo npm install -g grunt-cli, on my Windows 8 work laptop, Grunt was placed in the '.npm-global' directory: %USER_HOME%\.npm-global and I had to add that to the Path.
So on Windows my steps were:
npm install -g grunt-cli
figure out where the heck grunt.cmd was (I guess for some it is in %USER_HOME%\App_Data\Roaming)
Added the location to my Path environment variable. Opened a new cmd prompt and the grunt command ran fine.
On Windows 10 Add this to your Path:
%APPDATA%\npm
This references the folder ~/AppData/Roaming/npm
[Assumes that you have already run npm install -g grunt-cli]
I installed grunt as a development dependency. For some reason I had the NODE_ENV set to production (eg. export NODE_ENV=production) so when I run npm i what got installed were the production dependencies instead the development dependencies.
To get it fixed all I had to do was to fix the respective environment variable, so by export NODE_ENV=development followed by npm i the development dependencies installed as they should in the first place.
Probably this is a rare case but if nothing else works then it is worth checking these premises too.