broccoli-closure-compiler install error - node.js

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 )

Related

Node package dependencies on IBM Cloud Foundry - require/module is not defined (Package not loading)

I am working on an application via the toolchain tool on IBM Cloud and editing the code via the Eclipse Orion IDE. As I am not accessing this through my local cli, my understanding is that in order to so call npm install {package}, I would just need to include the package in the package.json file under dependencies and require it in my app. However, when I load the application, I get the require is not defined indicating that the package has not been installed. Moreover, the require() is being used in the app.js file with the application being launched but not from files in my public directory.
After playing around further, it seems it might have to do with the way the directory tree is being traced as the error is only thrown in subdirectories. For example, require('express') works in app.js which is in the main directory ./ but fails when it is called in test.js in ./subdirectory/test.js. I feel like I'm missing something painfully simple like configuration of endpoint or something.
I've been searching around but I can't seem to find how to get the packages loaded, preferably without using the cli. Appreciate any pointers. Thanks!
Update: After playing around further, I am also getting module is not defined error when trying to require from another file in the same directory. For example module.exports = 'str' returns this error. While trying to require('./file') returns the require is not defined. It might have to do with how node is wrapping the functions?
Update 2: Tried "start": "npm install && node app.js" in package.json but no luck. Adding a build stage which calls npm install before deployment also does not work
Update 3: After adding npm install build stage, I am able to see that the dependencies have been successfully built via the logs. However, the require is not defined error still persists.
Update 4: Trying npm install from my CLI doesn't work as well even though all packages and dependencies are present
Update 5: Running cf restage or configuring cache via cacheDirectories does not work as well
Opened a related question regarding deployment here
Found out my confusion was caused due to me not realizing that require() cannot be used on the client side unless via tools such as Browserify.

Not able to run composer rest server

While starting composer rest server I am getting error :
Connection fails: Error: Failed to load connector module "composer-connector-hlfv1" for connection type "hlfv1". Cannot find module '/home/user/.nvm/versions/node/v8.9.3/lib/node_modules/composer-rest-server/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64/grpc_node.node
there is no grpc_node.node file present in the above folder. I tried reinstalling compoer rest server but no luck.
There are lots of reasons for this. the grpc module is a binary module and usually npm will download a prebuilt binary for your platform. If however it cannot do that (eg server down, or the platform is not recognised) then it will attempt to build the binary from source.
You need to look at the output during the npm -g install of composer-rest-server to see what is reported when npm attempts to install grpc to determine what the problem is.
The following advice from another thread has worked for me. Please try:
Rebuild it
Go to the folder cd '/root/.nvm/versi ons/node/v8.9.1/lib/node_modules/composer-rest-server/'
(into the folder where you have 'composer-rest-server')
then run npm rebuild --unsafe-prem
It will work now
source - Error while generating REST api using hyperledger composer-rest-server in centOS

Trying to get MEAN maps to work on windows

I cloned this mean map that I watched on a azure mongodb video , and I did the same steps in the readme like they did
https://github.com/scotch-io/mean-google-maps
So
npm install
node server.js
// I didn't do any mongodb , as there is a config.js that is pointing at an amazon mongodb.
On the video they didn't do any mongodb locally
I see that in chrome console it throws an error with modernizr
#!/usr/bin/env node
That line is red squiggly , it that line causing the map to not load? Is that even going to work on a Windows 10 machine I'm running?
This error has nothing to do with mongodb.
The problem is the Modernizr link in the public/index.html (line 18) points to a script which is designed to be run server side.
The shebang #!/usr/bin/env node indicate a javascript file that must be run with Nodejs. Your browser can't run this kind of script.
It's looks like a confusion in bower dependency management.
(I think it is generaly not a good practive to include bower_components directory into git repository)
Maybe you can try to fix it by replacing the link with a cdnjs version of Modernizer:
https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.js
Or just delete the line, you use a recent Chrome browser after all...

running node.js sails app on openshift

I'm trying to deploy my node.js sails app on openshift. I followed procedure outlined in https://gist.github.com/mdunisch/4a56bdf972c2f708ccc6 but still doesn't work.
also try this: Node.js app on openshift
no matter what i'm getting "Service Temporarily Unavailable"
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later. Error.
Hopefully someone can at least point me to the right direction.
Thanks in advance.
I have also deployed my application onto openshift and here are my steps
Create a node.js Cartridges 0.10
In the repo, please mention "https://github.com/ryanj/nodejs-custom-version-openshift" since my sails need npm version 1.4.0 and the original one is 1.3.X
git clone the repo
copy your file into that repo
Follow this page https://gist.github.com/mdunisch/4a56bdf972c2f708ccc6
The first two steps should be done if you haven't changed the original stuff. The only things is to change ".openshift/action_hooks/pre_start_nodejs" and append that at the end to make it is as a production and run the grunt
git add . and git push
It will automatically build and at the end will tell you deployment completed with status: success
I am also new but hope you can try. Thanks
One more things, if missing the step 5, you won't run the sails and can't see the log in the terminal and result in 503 on browser.
But I have another question after each push on openshift, you can see my log if you want to know what is the right status
Why mongodb is reset after push to openshift
Another suggestion is to ssh and make sure the npm -v is larger than 1.4.0, try to npm install -g npm to update the version.
If still fails, i will suggest to npm install sails -g and try to commit and look for the build..

How to deploy apigee proxies with node target servers that use node modules that are not pre-installed?

This question is about deploying proxies with node target servers that use node modules that are not pre-installed. We use apigee edge running on-premises.
The node target servers runs fine locally.
The question is simple: How do I deploy such proxies with node target servers to apigee edge on-premises?
Attempt 1
I have tried packaging the proxy into a zip-file as usual and uploaded it in the web browser using the 'import into new revision' feature. It has worked fine for simpler proxies (that only use pre-installed node modules). All dependencies are listed in the packages.json file. When the proxy is deployed, every api call results in:
HTTP/1.1 500 Internal Server Error
Content-Type: application/json
Content-Length: 148
{"fault":{"faultstring":"Script node executed prematurely: Script exited with code 0","detail":{"errorcode":"messaging.runtime.ScriptExitedError"}}}
Attempt 2
I've also tried to install the modules locally using 'npm install' and then include the modules in the zip. However, in this case there is a red error message the import failed. When I reload the api proxy page in the web browser it seems like the package was actually uploaded, and the box that show loading progress goes to more than 2000%. However, when the loading has completed, it is not possible to deploy it (a standard unspecific error message is displayed).
Attempt 3
Finally I have also tried the apigeetool using the syntax at http://apigee.com/docs/api-services/content/adding-nodejs-existing-api-proxy (I did change the url in the python source code to our on-premises server). Before running the tool, the modules are installed using 'npm install'. The result is this error message:
Importing new application %PROXYNAME%
/v1/organizations/%ORGANIZATION%/apis?action=import&name=%PROXYNAME%
Import failed to
/v1/organizations/%ORGANIZATION%/apis?action=import&name=%PROXYNAME%
with status 404: {"fault":{"faultstring":"Classification failed for
host %IP%:%PORT%","detail":{"code":"CLASSIFICATION_FAILED"}}}
Assuming you're using OSX or a flavour of *nix:
Create a folder on your local machine to contain your Node script (e.g. /Development/myNodeProxy/). Place your script there. (e.g. server.js).
Open Terminal and cd to your script folder (/Development/myNodeProxy/).
Use npm to install the modules you need (type npm install {modulename} without the global -g switch). Caveat: Edge doesn't play nice with conflicting versions of Express, so you will need to npm remove express before deploying. You may need to remove other the modules that are preinstalled on Edge too if you end up getting errors (like errno 32 broken pipe).
From the same directory, run the following command:
apigeetool deploynodeapp -n {name-of-your-proxy} -o {org} -e {environment} -b {proxy-basepath} -d ./ -m server.js -u {your-email-address/username} -p {password}

Resources