I'm trying to set up msnodesql (formerly node-sqlserver) with my azure hosted site and am running into some issues.
Essentially I'm getting a deployment failed within Azure. I believe it is due to the fact NPM is trying to install msnodesql on the server but will fail because it would need "node-gyp", Python and C++ 2010 installed (which is not present on the azure side). Here is the error message I'm seeing
npm ERR! msnodesql#0.2.0 install: `node-gyp rebuild`
npm ERR! `cmd "/c" "node-gyp rebuild"` failed with 1
npm ERR!
npm ERR! Failed at the msnodesql#0.2.0 install script.
npm ERR! This is most likely a problem with the msnodesql package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls msnodesql
npm ERR! There is likely additional logging output above.
I've been hacking at this error for a while now and nothing seems to fix it. The best answer I've gotten is to manually include the msnodesql within node_modules (as specified by http://geekswithblogs.net/shaunxu/archive/2012/11/16/install-npm-packages-automatically-for-node.js-on-windows-azure-web.aspx ). I feel like that should fix it but alas it does not. I also tried compiling it against the local x86 node and also just using a prebuilt x86 one (suggested by http://geekswithblogs.net/shaunxu/archive/2012/09/18/node.js-adventure---when-node.js-meets-windows-azure.aspx ).
Any other suggestions would be appreciated here.
Also worth noting is it's working in my local environment just fine and can grab data in from the SQL Azure DB I created (once i've whitelisted my IP) using msnodesql running within webmatrix but hitting Azure SQL DB.
I originally had an issue with the DB and the Website in Azure being on different regions, but I corrected that.
As Glenn Block mentioned, the problem stems from Azure tyring to build the native module when you deploy. This can happen for a few reasons, maybe you didn't upload the binary, maybe it's the wrong binary, or maybe the deployment directory got screwed up.
The Azure server wants the 32 bit driver for Node .6.
What I had to do was FTP into my azure server and delete everything in /site/wwwroot/ except for web.config. You can probably get away with just deleting node_modules, but because the behavior was unexpected I wanted to clean out everything.
Then I went into my Node project directory on my local machine, and went into the node_module/msnodesql directory and deleted everything but package.json and lib directory. In the lib directory, I created separate directories for the binary for my dev machine(64 bit .8) and azure, called 64 and 32 respectively.
I then modified, sqlserver.native.js as follows
try {
module.exports = require('./32/sqlserver.node'); //Azure version
}
catch (e) {
try {
module.exports = require('./64/sqlserver.node'); //My local machine
}
catch (e) {
try {
module.exports = require('../build/Release/sqlserver.node');
}
catch (e) {
console.error('Native sqlserver module not found. Did you remember to run node-gyp configure build?');
throw e;
}
}
}
The big point to make here is that, we try to load all available versions to accommodate for every possibility of deployment I might have, but give priority to the Azure server. On my local dev machine, we failed to load the node from /32 since it's the wrong format, and we fall back to /64.
I bet if I put a little bit of effort into this, I could easily trim what gets deleted down to the bare minimum, but after wasting hours upon hours resolving this, I had enough.
The reason this is failing is because it is trying to build the native module when you deploy. We don't support building native modules in Windows Azure Websites. You can however deploy the binary and then it will work but you would need to not have it in your package.json. Follow this post for more details: http://blogs.msdn.com/b/sqlphp/archive/2012/06/08/introducing-the-microsoft-driver-for-node-js-for-sql-server.aspx
Related
I'm a newly hired employee trying to get NPM to work on the machine I just got from my company (Lenovo P15s with Windows 10). No matter what I try to fetch with NPM, I get the following error:
request to https://registry.npmjs.org/#angular%2fcli failed, reason: write EPROTO 10540000:error:0A000152:SSL routines:final_renegotiate:unsafe legacy renegotiation disabled:c:\ws\deps\openssl\openssl\ssl\statem\extensions.c:922:
NPM init works fine.
What I've tried so far:
Checked proxysettings to see if I'm behind a proxy (I'm not, as far as I can see - the settings are all clear)
Removed and reinstalled Nodejs and NPM several times, both through the Windows installer and through NVM/cli
Running "NPM install" from Node version 19.4, 18 and 17 with correlated NPM-versions. Same error regardless
Turning off strict-ssl (I'm aware of the risk, just tried for test purposes) - on Node v17+ I get the same error, but turning off strict-ssl on v16 gives me this error instead:
errno SELF_SIGNED_CERT_IN_CHAIN ERR! request to https://registry.npmjs.org/#angular%2fcli failed, reason: self signed certificate in certificate chain
Testing on another clean machine from the company still gives me the EPROTO error
Setting the NPM-registry with "npm config set registry http://registry.npmjs.org/"
Setting NODE_TLS_REJECT_UNAUTHORIZED=0 (I know this is risky as well).
No luck.
I have read that you can set the path to a certificate-file in the config file, but walking down that whole certificate-road, I honestly have no idea what I'm doing. I downloaded a DigiCertHighAssuranceEVRootCA-certificate and tried pointing the path to that, no change at all.
Any suggestions on what I'm missing or what I can do?
Like this question How to import private Azure repo into a project via HTTPS? I'm trying import a repository like a dependency inside the package.json in another project.
This answer https://stackoverflow.com/a/61906140/8468940 seems to be good but I couldn't make it work.
When I tried this way
"commons-js": git#ssh.dev.azure.com:v3/tiagoaleff/commons-js/commons-js
I got the following response:
Could not install from "git#ssh.dev.azure.com:v3\tiagoaleff\commons-js\commons-js" as it does not contain a package.json file.
But I have a package.json in my commons-js. I also tried another ways and urls but without success.
I also tried this way:
git+ssh://account#ssh.visualstudio.com:v3/tiagoaleff/commons-js/commons-js
But after some time I got this error:
npm ERR!
npm ERR! undefined
npm ERR! exited with error code: 128
Unfortunately I'm in trial and error mode. I don't know If in the company I can use the pipelines and I don't know have experience with this process.
Maybe this approach isn't enable? Or maybe, is pipeline the only solution?
Thanks you guys for your patience and sorry by my English.
If a run my current nodejs project, it crashes as soon as FireStore is accessed (the problem started when I moved to a new Windows laptop):
Assertion failed: new_time >= loop->time, file c:\ws\deps\uv\src\win\core.c, line 309
npm ERR! code ELIFECYCLE
npm ERR! errno 3221226505
The cause has been identified to be a VS compiler bug affecting libuv and has been fixed in libuv with a workaround:
https://github.com/libuv/libuv/issues/1633
To the best of my understanding, libuv is a dependency of nodejs. The relationship to FireStore seems to be more of a coincidence. So how can I get a working nodejs environment that incorporates the fix (or is not affected by the bug)?
(I'd rather not go the WSL route proposed by others as I would need to considerably change my development setup.)
Actually for me also got the same error. This GitHub issue made me to solve the problem.
it says like
Clock synchronization, obviously, shouldn't help in most cases. I've
build 14.4.0 version with this patch, it works. Maybe it'll help
someone. Simply, download node.zip and replace node.exe in folder,
where NodeJS 14.4.0 is installed.
I am trying to use Protocol Buffers - Google's data interchange format referring https://github.com/google/protobuf/tree/master/js
I tried to follow documentation i am able to get the setup of Protocol Compiler and able to do
protoc --js_out=library=myproto_libs,binary:. messages.proto
but when i do npm install google-protobuf i am getting
npm ERR! 404 Registry returned 404 for GET on https://registry.npmjs.org/google-
npm ERR! 404
npm ERR! 404 'google-protobuf' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
and if i write the sample which can use that generated binary it says goog is not defined
goog.require('com.nec.eva.msap.proto.alerts.FaceAlert');
var message = com.nec.eva.msap.proto.alerts.FaceAlert();
message.watchlist_id("1");
message.candidate_id("25");
message.gender("female");
bytes = message.serializeBinary();
I am not sure why i am not able to do npm install and also how that goog.require('com.nec.eva.msap.proto.alerts.FaceAlert'); will use the generated binary please help i have almost spent a day to understand but not getting it
There are issues and
the API is not well-documented yet
You need to compile it with protoc messages.proto --js_out=import_style=commonjs,binary:.
Or set
var jspb = require('google-protobuf')
var goog = jspb
Best to search on http://node-modules.com/search?q=protocol+buffers. This one is popular and should work: https://github.com/dcodeIO/protobuf.js
Simply, google-protobuf is not in the npm repository, so installing it will not work (see https://www.npmjs.com/package/google-protobuf). However, there are a number of protocol buffers libraries that you could try:
https://www.npmjs.com/package/protocol-buffers this one plays a bit fast and loose, but is really good for many simple cases (and it's blindingly fast).
https://www.npmjs.com/package/protobufjs aims to be a bit more complete; I haven't personally used this one, but it's well regarded and has a large number of downloads.
We are trying to move a node.js app that requires node v0.11.x to Azure WebSites.
When trying to use azure-node-runtime-selector to install node v0.11.x, we encounted what seems a bug caused by nodist installing npm 2.0.0-alpha.
Below the output of call to nodist update:
1 file(s) copied.
npm http GET https://registry.npmjs.org/npm
npm http 304 https://registry.npmjs.org/npm
npm http GET https://registry.npmjs.org/npm/2.0.0-alpha-5
npm http 304 https://registry.npmjs.org/npm/2.0.0-alpha-5
D:\home\node\nodist\bin\npm -> D:\home\node\nodist\bin\node_modules\npm\bin\npm-cli.js
npm#2.0.0-alpha-5 D:\home\node\nodist\bin\node_modules\npm
'ode' is not recognized as an internal or external command,
1 file(s) moved.
operable program or batch file.
Install dependencies...
Any ideas on how to either solve this or, alternatively, how to force nodist to keep using npm v1.4.*?
If you don't mind an alternative solution, you can use this guide under the section "Using a custom version with Azure Web Sites". The only important step is to bring your own node.exe with your app, and set "nodeProcessCommandLine: " in iisnode.yml to your node.exe's path.
Edit: See github.com/mtian/custom-version for an example.
Looks like there's a typo somewhere (it's failing on 'ode' which should probably be 'node'). You could try finding where that typo is coming from and fix it.