Deploy to azure website and run grunt build tasks - node.js

I am trying to get continuous integration working for my Azure website which uses grunt, npm and bower to build.
I have followed the instructions here: http://www.cptloadtest.com/2013/12/03/Git-And-Grunt-Deploy-To-Windows-Azure.aspx and have modified my deploy.sh deployment section to match.
When I deploy I get the following error message:
Command: bash deploy.sh
Handling node.js grunt deployment.
An error has occurred during web site deployment.
C:\Program Files (x86)\SiteExtensions\Kudu\45.40522.1562\bin\scripts\selectNodeVersion.js:115
select node version failed
throw new Error('Usage: node.exe selectNodeVersion.js <path_to_repo> <path
^
Error: Usage: node.exe selectNodeVersion.js <path_to_repo> <path_to_wwwroot> [path_to_temp]
at Object.<anonymous> (C:\Program Files (x86)\SiteExtensions\Kudu\45.40522.1562\bin\scripts\selectNodeVersion.js:115:11)
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)
at startup (node.js:119:16)
at node.js:906:3
Does anybody know what I could try next?

I also had some problems doing build and deployment in visual studio online. I added a command line "npm.cmd cache clean" at the top of my build definition. That made it work. Maybe that helps you too.

Related

Lambda: module initialization error: Error

I'm getting this error when I deploy my Lambda function:
module initialization error: Error
at Error (native)
at Object.Module._extensions..node (module.js:597:18)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at bindings (/var/task/node_modules/bindings/bindings.js:84:48)
at Object. (/var/task/node_modules/sharp/lib/constructor.js:10:34)
at Module._compile (module.js:570:32)
The serverless.yml and package.json:
https://github.com/A-Atrash/forfilesharingtohandleerror.
It's with Node. It used to work before I added a new package ImageMagick and started using it as an image validation. Any idea?
I believe you're creating your Lambda package from non-Linux environment (e.g. Windows or MacOS).
ImageMagick uses native modules so you when you do your npm install, it compiles it for your current environment. If you're in Windows or MacOS, this compiled package will not work Lambda (which uses Linux).
For it to work, your Lambda package has to be created in a Linux environment and then uploaded from there.
In my case it was source-map-support package that discarded the actual error message and stack trace.
Once I commented out the source-map-support package import line then the error started showing the actual error message and stack trace.

Use nodeclipse plugin

I'm using nodeclipse plugin in eclipse to start working with nodejs and expressjs ,but when i create expressjs project and try run app.js file i get this error
/home/ali/node_modules/express/lib/express.js:99
throw new Error('Most middleware (like ' + name + ') is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.');
^
Error: Most middleware (like favicon) is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.
at Function.Object.defineProperty.get (/home/ali/node_modules/express/lib/express.js:99:13)
at Object.<anonymous> (/home/ali/node-WS/express01/app.js:18:16)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.runMain (module.js:575:10)
at run (bootstrap_node.js:352:7)
at startup (bootstrap_node.js:144:9)
How can i fix this problem?
This means You have to install module separately. Maybe you're using latest version of expressJS.
installing modules separately will solve your problem!

NodeJS CLD package external dependency

I had problem installing CLD package into one of my machine, so I tried to install it into another machine and the installation works perfectly.
In the good machine, I installed the CLD package and wrote a simple app.js around it.
var cld = require('cld');
console.log('cld loaded');
When running this in the good machine, I receive console output "cld loaded" as expected. I copied the exact same code including the node_modules folder into the other machine and run it, I receive errors in the console output:
E:\Test>node app.js
module.js:423
return process.dlopen(module, path._makeLong(filename));
^
Error: The specified procedure could not be found.
\\?\E:\Test\node_modules\cld\build\Release\cld.node
at Error (native)
at Object.Module._extensions..node (module.js:423:18)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (E:\Test\node_modules\cld\index.js:2:12)
at Module._compile (module.js:398:26)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
I can confirm the file "E:\Test\node_modules\cld\build\Release\cld.node" is existing. I'm not sure what's the missing procedure here. I suspect there could be some external dependency required for the package.
Could anyone advise what could be the external dependency missing in the first installation?
Figured out it's a node.js version issue. I downgrade my nose.js to 0.10.28 and it works fine. I suppose it's some bug to be fixed by CLD.

Cannot find module 'express-session'

I am trying to run sparkleshare-dashboard. This is an open source project you can see it here
https://github.com/tommyd3mdi/sparkleshare-dashboard.
The project use Node.JS and Redis and i have no experience with both. I did setup the environment as described in the help file and then i try to run file app.js from command line using 'node' command but i got this error.
Error: Cannot find module 'express-session'
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> (E:\Imports\sparkleshare-dashboard\app.js:5:15)
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)
Maybe i didn't provide enough information but i am expecting that may be some of you guys has done some work on sparkleshare project and may someone can help me in this.
The reason is likely your ">" operator for express in the package.json.
Express 4.0 is out now and the complete middleware concept changed.
You need to install these middlewares manually.
"express-session" is one of the 4.0 middlewares.
I recommend to read
http://scotch.io/bar-talk/expressjs-4-0-new-features-and-upgrading-from-3-0
and
https://github.com/visionmedia/express/wiki/Migrating-from-3.x-to-4.x
Additionally some users were confused that the github repo is named just "session" but
npm install express-session
is correct.
Make sure you have installed express-session. You can check for the directory inside your node_modules folder or you can also chekc your dependencies inside your package.json file

Require cannot find custom module after moving to server

I am trying to deploy a node app that runs fine on my local Mac Lion, however. On the virtual Ubuntu box, it is giving an error:
module.js:340
throw err;
^
Error: Cannot find module '../lib/review'
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> (/home/websites/Node_apps/min-driver-node/routes/reviews.js:2:14)
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 Module.require (module.js:364:17)
There is my own custom modules in ./lib folder that are 'require' from the routes as following:
var Review = require('../lib/review');
What have I tried?
Ensured the same Node.js version running via
nvm(https://github.com/creationix/nvm)
Removed node_modules just to
re-install them by running "npm install"
Why is the 'require' unable import the custom modules from 'lib' folder on Server while works on Mac? Thank You
Try using the complete path to the file instead of using the relative path (../).
It looks like the 'require' module is case sensitive on Ubuntu but not on Mac....all my modules in lib folder starts with upper case(i.e. lib/Review.js), but when required in other parts of the code, it is lower case - require('../lib/review'). This is causing issue on Ubuntu but not on Mac lion. By updating the code to 'require('../lib/Review'), solves the problem
Is this a bug and i should be reporting this?
Try set file permissions chmod -R 744 '../lib/review'

Resources