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.
Related
I'm trying to get the list of files from a local package that would be published by npm. The best solution I've come by is to use
npm publish --dry-run
through child_processes.spawn(...) or a related method.
However, this is not very reliable as I need to parse the text output that is not guaranteed to be/stay the same in all environments/future releases.
Of course, I could npm pack and list the contents of the tarball, but that is rather outside the scope of my project, as for instance I wouldn't want to rely on being able to write to the filesystem.
So, is there a "semantic" way to access the data returned by npm publish?
To answer my own question:
The specific case I was having trouble with was solved using the json option that I was not aware of at the time I posted the question:
npm pack --dry-run --json
through child_processes.spawn, which at least produces semantic results.
To the general question, i.e., whether it was possible to call npm functions directly, not through spawning, the answer seems to be NO.
I tried installing npm as a library:
npm install npm
and then in the javascript source
const Pack = require('npm').Pack;
resulted in an enlightening
Error: The programmatic API was removed in npm v8.0.0
I'm getting this output when trying to install a node application using npm install:
$ npm install
> ejs#2.7.4 postinstall /home/dh_8u42k7/quotegoodeair.com/node_modules/ejs
> node ./postinstall.js
/home/dh_8u42k7/quotegoodeair.com/node_modules/ejs/postinstall.js:9
let envDisable = isTrue(process.env.DISABLE_OPENCOLLECTIVE) || isTrue(process.
^^^
SyntaxError: Unexpected strict mode reserved word
I have already found this question which contains a workaround. However, this isn't my own code, so I can't just remove "let", it seems to be a problem with ejs itself.
For another thing, the file postinstall.js doesn't even exist, even the ejs folder doesn't exist, so I can't just go in and edit the file.
Is there something wrong with my node application, or with ejs, or maybe with npm or Node itself? Why does Node install components which aren't supported by Node? Why does Node tell me there's an error in a file which doesn't exist?
It may be that your version of node does not support the features in the application you are trying to install.
One solution may be to find out what the version of node the application that you are trying to install originally used.
I believe you can check the engine field in your package.json file.
If you local node version is different, and you need to change it, here is a link to a question providing that information: How can I specify the required Node.js version in package.json?
I also found this post interesting: https://github.com/tj/n/issues/472
It's for a different application but they received the same error message. The issue was conflicting npm folders. It's possible that the program that you are trying to install is conflicting with your existing npm setup if you have other nom folders in the directory you are installing the application in.
Ultimately, given the information you provided, I think your best bet it to look in the package.json file of the application you're trying to install and see if your local setup is conflicting with how the program is trying to be installed or run.
I was trying to change my npm and npm-cache folders to d:\\npm-global and d:\\npm-cache
I managed to do a npm config set cache d:\npm-cache
When I tried to do a npm config set prefix d:\npm-global I accidentally put a ' in the folder string as I was hitting enter. I deleted the errant folder after trying a npm i -g gulp and to my horror, npm stopped working altogether, it just sits there with my command prompt rocking up to 50% CPU usage.
Help please! I've tried searching the registry and other places, even uninstalled and re-installed the nodejs msi package on Windows. This reset the D:\Program Files\nodejs\node_modules\npm\npmrc file.
Still no luck. I can't get npm to work again. :(
edit A little digging in and I realized there is a second node server running via Adobe Creative Cloud. I doubt this is the problem though as when I run npm from the cmd.exe prompt, the correct (d:\program files\nodejs) version of the npm server is executed for that process.
edit so only sometimes when I hit Control-C, I'll get this error:
seems like it's trying to find a file that doesn't exist. However, I cleared out the AppData\Roaming\npm folder and the reinstalls reset the default d:\program files\nodejs\....npm\npmrc file. I also made sure that the environment variable NODE_PATH is not set. It wasn't set when it was working. I set it when I was trying to make my changes.
You should be able to modify your config settings manually by modifying ~/.npmrc
#jakemingolla was right so I marked that answer as accepted (thanks Jake), but I also asked this in the NPM forum and did a little test after I got it working. I thought this might help someone: https://npm.community/t/i-killed-my-npm-on-windows-trying-to-move-some-folders-reinstalling-nodejs-isnt-resetting-the-problem/5743/8?u=chi11ax
I am trying to test es-6 promise-polyfill, for the testing one the node packages requried is broccoli-closure-compiler, which is not getting installed, I am behind a proxy server, is that the problem, but i have proxy config for both git and npm, so they are working fine, for more info, please refer to the screenshot of the command prompt,
edit:
the text in screenshot
D:\pt>npm install broccoli-closure-compiler
npm WARN package.json jshint#0.9.1 No repository field.
\
closurecompiler#1.3.2 install D:\pt\node_modules\broccoli-closure-compiler\node_modules\closurecompiler
npm run-script configure
\
closurecompiler#1.3.2 configure D:\pt\node_modules\broccoli-closure-compiler\node_modules\closurecompiler
node scripts/configure.js
Configuring ClosureCompiler.js 1.3.2 ...
Downloading http://dl.google.com/closure-compiler/compiler-latest.tar.gz ...
? Download failed: Error: connect ETIMEDOUT
? Unfortunately, ClosureCompiler.js could not be configured.
See: https://github.com/dcodeIO/ClosureCompiler.js (create an issue maybe)
what I am suggesting is not a solution, these are mere work-around( aka really bad hacks)
if you are facing this, it is because you are behind a proxy server and one of the scripts trying to install clousurecompiler does not have the proxy settings set.
work around one : well, find a way to connect without proxy server, or install in a machine outside proxy server, copy the node_module files to your system,
work around 2 (the one I used) :
when you look at the screenshot, you would notice that at one point "node scripts/configure.js" is run, this is the crucial point, find a way to pause the processing just before this point,
open the 'configure.js' file, it would be at '.\node_modules\broccoli-closure-compiler\node_modules\closurecompiler\scripts' in node project directory,
comment line 65 in that i.e fail(); to //fail();
continue the installation process,
manually download http://dl.google.com/closure-compiler/compiler-latest.tar.gz , put the extracted file at '.\node_modules\broccoli-closure-compiler\node_modules\closurecompiler\compiler' in your project directory
(... told you this is a bad solution )
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