Azure Website Deploy Error: install.js: Unable to download msnodesql-0.2.1-v0.10-ia32.msi - node.js

Right now, I am trying to set up Node.js website connect to Azure SQL(Not MySQL).
I have created a simple program to get data from Azure mssql database.
On local it works fine.(It retrieves info from Azure MSSQL)
However, when I try to deploy, I get "deployment error".
Here is the gist of error I get.
npm ERR! weird error 1
install.js: Unable to download msnodesql-0.2.1-v0.10-ia32.msi
Failed exitCode=1, command="D:\Program Files (x86)\nodejs\0.10.21\node.exe" "D:\Program Files (x86)\npm\1.3.11\node_modules\npm\bin\npm-cli.js" install --production
An error has occurred during web site deployment.
npm
My package.js is as follows
{
"name": "application-name",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app.js"
},
"dependencies": {
"express": "3.4.8",
"jade": "*",
"nconf": "~0.6.9"
}
}
Inside, node_modules, there is also mnodesql folder which I downloaded from GitHub[https://github.com/WindowsAzure/node-sqlserver]
I run the following code too.
node-gyp configure
node-gyp build
I would appreciate any advice you can offer.
Thanks.

AFAIK, node-sqlserver needs C++ environment to compile the source code but there's no C++ compiler in Azure Website. What I did is to compile this module on local machine and upload as part of my source code. I covered this scenario at the bottom of my blog http://wblo.gs/dLo.
Hope this helps.

Related

Azure expressjs web apps

I have created an express application in Visual Studio. I am having problems running it in azure once I've hosted.
It does not seem to find my node_modules folder.
Whenever I deploy and visit the site, on Kudu under the /logStream url I receive the error
cannot find module 'debug'
I found out that the debug module was required in the www folder. I then removed it from there and redeployed.
After redeployment I get
cannot find module 'express'
When I run my app in production (locally), I do not experience these problems.
One suggestion was removing the node_modules folder and then publish to Azure, with that you then use npm install on Kudu powershell or cmd. I have tried this and the same errors still come back. Could you please direct me on how I can resolve this?
package.json:
{
"name":"app-name",
"version":"0.0.0",
"private":true,
"scripts":{
"start":"node ./bin/www"
},
"description":"descrt",
"author":{
"name":"myname",
"email":"myemail#smtpserver.com"
},
"dependencies":{
"body-parser":"~1.8.1",
"cookie-parser":"~1.3.3",
"debug":"~2.0.0",
"express":"~4.9.0",
"jade":"~1.6.0",
"morgan":"~1.3.0",
"request":"^2.72.0",
"serve-favicon":"~2.1.3",
"stylus":"0.42.3"
}
}

Amazon Elastic Beanstalk npm cant find package.json

I'm very new with amazon web services, and I am trying to set up a node.js app on their elastic beanstalk. I set up the instance and uploaded/deployed the site, but while the health is "Ok" the node.js logs show this repeated about 30 times:
npm ERR! enoent ENOENT: no such file or directory, open '/var/app/current/package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /var/app/current/npm-debug.log
npm ERR! Linux 4.1.13-19.31.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v4.2.3-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v4.2.3-linux-x64/bin/npm" "start"
npm ERR! node v4.2.3
npm ERR! npm v2.14.7
npm ERR! path /var/app/current/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
The problem is that my package.json does exist because I generated one with npm init. Any ideas on why it cant be found? Here is the package.json
{
"name": "testwebsite",
"version": "0.0.1",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"body-parser": "^1.13.3",
"express": "^4.13.3",
"express-session": "~1.0.0",
"socket.io": "^1.3.7"
},
"description": "my website",
"author": "Matt",
"engines": {
"node": ">=0.10.0"
},
"main": "server.js",
"devDependencies": {},
"license": "ISC"
}
From an official AWS thread[1], it appears (and this was my problem) that you might be zipping the top-level directory rather than zipping the source itself.
For example, you may have all of your files in a folder called "Project". Rather than zipping "Project", you should zip and upload the contents of "Project".
[1] https://forums.aws.amazon.com/thread.jspa?messageID=476022
I had a problem the same as - or very similar to this, and it was caused the fact that my code was listening to a custom port, instead of the one that Elastic Beanstalk sets as an environment variable (8081).
I fixed this setting in the port near top of my app.js or server.js file, just after I create the express app. For example:
var app = express();
app.set('port', (process.env.PORT || 5000)); // 5000 was my original port
Then using this port in the app.listen method instead of my own custom port number:
app.listen(app.get('port'), function () {
console.log('Server has started! http://localhost:' + app.get('port') + '/');
});
More details here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs.container.html#nodejs-platform-proxy
I was having these odd error on AWS EB as well. I was generally deploying using the CLI.
couple things to try.
make sure the package.json is not in your .gitignore file, to ensure it is being committed to your repository. EB uses the git commit history to decide what to zip and send. If that isnt included it is not on the AWS servers
i was using the t2.nano instance (512MB space) option for EC and that seemed to be an issue because I had a lot of modules in my package.json. Wasnt sure if that was the root issue of my woes but my error messages changed when I upgraded to an instance that had at least 1GB of space.
hope this helps
I was having something similar whereby the elastic beanstalk deploy failed when using the eb cli. I realized that the elastic beanstalk config files had inadvertently been added to my .gitignore file causing the deploy to fail.
I had trouble with the zipping, etc. I recommend using CodePipeline and linking it to your github or AWS codecommit. Then, skip the build stage, and for the deploy stage click elastic beanstalk.
You will have to pause the process and open a new tab and go to EB and create a new environment. Make sure you click nodeJS in this example. Make sure you choose "sample code" so that AWS can set it up with their template. Once the EB is finished building you should have a link to the template that is functional.
Then you can go back to your CodePipeline tab and click on Elastic Beanstalk for deployment and you should find the EB you just made.
I recommend this process because it will automatically update every time you do a git change. This is better than zipping a file, etc.

npm start Microsoft JScript runtime error 800A138F object expected

Getting started with NPM...
I can run the following command to start my app.
node app
But when I run the following command, I get the following error:
npm start
Windows Script Host
Object expected
Line 2
800A138F
Microsoft JScript runtime error
App.js:
var port = 5000;
var express = require('express');
Package.json:
{
"name": "2",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"start": "app.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.13.3"
}
}
And I've run this command of course:
npm install express --save
Seems like NPM can't find the express package? Why not?
I know its too late to answer, but in case any wanderer like me faces the same problem in future..
Solution:
need to add node keyword ahead of app.js in script. So, start script should
"scripts": {
"start": "node app.js"
},
That solved for me.
I had this problem as well. The .js files are associated with the Microsoft Script Engine. Some suggested that we dis-associate the extension with the program, but I do not think that is necessary. I was able to fix the issue with the following instruction that I found in the NODE Docs.
Please make sure that your file(s) referenced in bin starts with
#!/usr/bin/env node
otherwise the scripts are started without the node executable!
Use >node app.js instead of >app.js
Then it will work
When I faced the same problem using Visual Studio Code, I was trying to run localhost at port 8080, however by pressing F5 I was able to know that the port was already taken and so I changed the port to 3000, and viola! that worked for me.
Check out the error
If you're using Visual Studio Code, it may have taken over running the script. If in VS Code, hit F5 and see if the project runs properly.
I don't know why it does this, but did for me. This tipped me off

Bluemix error: Module version mismatch

I am trying to run a node.js application that uses PouchDB (a local CouchDB implementation). I can run this successfully locally and even upload it and build it on my Bluemix instance. However, whenever I send a request to my app, I do not get a response and I see the following error in my Bluemix console:
[Error: Module version mismatch. Expected 46, got 14. This generally implies that leveldown was built with a different version of node than that which is running now. You may try fully removing and reinstalling PouchDB or leveldown to resolve.]
I have tried to add npm rebuild into my build pipeline above the npm install, which I can see does indeed do a rebuild. However, I still get the previous error.
A bit about my app: It is a bot for the Slack platform. A user sends a command and my Bluemix app then responds. My Bluemix app has multiple documents that PouchDB stores. As I say, all this runs and responds correctly on my development machine.
Here is my package.js for reference:
{
"name": "XXXXXXXXXXX",
"version": "0.x.0",
"description": "XXXXXXXXXXXX",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"repository": {
"type": "git",
"url": "XXXXXXXXXXX"
},
"keywords": [
"slack",
"bot",
"nodejs"
],
"author": "xxxxxxxxx",
"license": "MIT",
"dependencies": {
"bluebird": "^3.1.1",
"body-parser": "^1.14.2",
"cfenv": "^1.0.3",
"cheerio": "^0.19.0",
"express": "^4.13.3",
"pouchdb": "^5.1.0",
"request-promise": "^1.0.2"
},
"engines": {
"node": "^4.2.x",
"npm": "^2.14.x"
}
}
Also some additional history: I ran a prior version of my app on Bluemix when I was using MongoDB instead of PouchDB. My node version at the time was the default that Bluemix gave me when I started, which was version 0.12.x. However, this version didn't support arrow functions, which I make heavy use of now. Hence, the bump to node 4.2.x.
Thanks!
Edit: After some digging I found out that 'leveldown' (a dependency of PouchDB) makes use of npm prebuilds where available. What this means is that if a prebuild is available on their GitHub it will be downloaded instead of the source, as a convenience. Looking through the logs I notice that version 1.4.2 is being downloaded as the prebuild version through Bluemix. However, there is a version 1.4.3 available that looks like it solves my 'Expected 46, got 14` issue. So the new question is why is Bluemix doing this and how can I rectify it?
I tried to push on Bluemix the same version that you are using ("^5.1.0") in your package.json and it is working fine, even using node engine "4.0.x".
Moreover according to CF infrastructure, the runtime is build during application staging step, so the pouchdb module should be built with the right dependencies and references.
Have you tried to push your application again in order to force a full application restage?
If yes, the first step to understand what is going on is to get the application logs during the staging process and also as soon as this error message is returned.
So, on your terminal, run the following commands:
1 - cd into your source directory
2 - connect to Bluemix API
cf api https://api.[REGION].bluemix.net

where [REGION] is one of
eu-gb for United Kingdom
ng for US South
au-syd for Sydney
3 - Login to Bluemix and choose the right ORG and SPACE
cf login -u [BLUEMIX USERNAME]
cf target -o [BLUEMIX ORG] -s [BLUEMIX SPACE]
4 - push your application and, as soon as it has been staged, run
cf logs [app-name] --recent > staging_output.txt
5 - tail the application logs, running
cf logs [app-name]
and without closing it make the request that is generating the error message
6 - check the output generated at step #5 for details on where in the code your application is failing and on the failing module
After a lot of debugging the answer, as ever, was to delete my Bluemix application first and then push a new version via the build system. The leveldown prebuilt npm package that was causing the error was cached somewhere. I could only get rid of this by deleting my app. Nothing special there.

Have you got nightmareJS working properley on c9.io IDE

NightmareJS on c9.io is literally a nightmare.
i cannot get it to work at all i am going to run through the whole process from start to finish.
Step 1
I create a new workspace
Hosted
Node.js
Step 2
Start Editing my new workspace
I open Package.json and add what i need heres my file.
{
"name": "chat-example",
"version": "0.0.0",
"description": "A chat example to showcase how to use `socket.io` with a static `express` server",
"main": "server.js",
"repository": "",
"author": "Mostafa Eweda <mostafa#c9.io>",
"dependencies": {
"async": "~0.2.8",
"express": "~3.2.4",
"socket.io": "~0.9.14",
"phantomjs": "*",
"casperjs": "*",
"nightmarejs": "*",
"utils": "*",
"crypto": "*"
}
}
i then run 'npm install' in the console.
Step 3
this is where it does not work i try all theses diffrent commands to get the examples running and the errors i get.
#stackoverflow:~/828481 $ cd node_modules/nightmarejs/examples/
#stackoverflow:~/828481/node_modules/nightmarejs/examples $ node server.js casper.js
Error: Cannot find module 'crypto'
phantomjs://bootstrap.js:289
phantomjs://bootstrap.js:254 in require
/var/lib/stickshift/5345392f50044693d40008de/app-root/data/828481/node_modules/utils/utils.js:7
/var/lib/stickshift/5345392f50044693d40008de/app-root/data/828481/node_modules/utils/utils.js:117
/var/lib/stickshift/5345392f50044693d40008de/app-root/data/828481/node_modules/utils/utils.js:118
Error: Cannot find module 'casper'
phantomjs://bootstrap.js:289
phantomjs://bootstrap.js:254 in require
/var/lib/stickshift/5345392f50044693d40008de/app-root/data/828481/node_modules/nightmarejs/lib/nightmareClient.js:4
/var/lib/stickshift/5345392f50044693d40008de/app-root/data/828481/node_modules/nightmarejs/lib/nightmareClient.js:83
TypeError: 'undefined' is not a function (evaluating 'require(phantom.args[3].slice(13)+'nightmareClient.js').Nightmare({
exitOnError: false
})')
/var/lib/stickshift/5345392f50044693d40008de/app-root/data/828481/node_modules/nightmarejs/lib/nightmareTest.js:16
I have it working. I also had trouble at first. I tried downloading the prebuilt package, but I can't seem to get that working. I ended up just adding the following to my package.json file and ran npm update and all was well:
"nightmare": "^1.5.0",
"phantomjs": "~1.9.7"
Probably they've updated the npm repo and everything since you've posted this. I bet it was frustrating. I don't have those examples in my install, but I would guess you could run them if you had all of the right pre-req's installed.

Resources