I use this buildpack in order to use casperjs on heroku.
Once my app created, I check my PATH
$ heroku config:get PATH
/usr/local/bin:/usr/bin:/bin:/app/vendor/phantomjs/bin:/app/vendor/casperjs/bin
OK, casperjs is in here!
--
Procfile
scraper: node scraper.js
scraper.js
var exec = require('child_process').exec;
exec('casperjs casper-script.js');
--
But when I launch the scraper process, it crashes with the following logs:
2012-10-09T02:23:38+00:00 heroku[scraper.1]: Starting process with command `node scraper.js`
2012-10-09T02:23:39+00:00 app[scraper.1]: bash: node: command not found
Why exec does not find casperjs which is in the PATH ?
PS: I tried with spawn but no more luck...
[EDIT]: a testable gist here https://gist.github.com/3856317
Got it!
#vinayr: you were right, neither exec nor casperjs command was involved in this issue, it was node which was the command not found!
I thought installing a buildpack with phantomjs and casperjs (eg: heroku-buildpack-casperjs) would have kept node capabilities for my app, but it does not seem so.
To make it work (node+phantomjs+casperjs) I rather had to fork the heroku-buildpack-nodejs buildpack and add phantomjs/casperjs binaries to it, which I could have called: heroku-buildpack-nodejs-casperjs.
In other words, when using a custom buildpack, you have to include the node support yourself .
Related
I am using luminus to build a webpage. I want to use clojure script so I created a project with
lein new luminus test +cljs
When starting the webpage I get the following message:
If you're seeing this message, that means you haven't yet compiled your ClojureScript!
Please run shadow-cljs watch app to start the ClojureScript compiler and reload the page.
so I installed and tried to run
npx shadow-cljs watch app
and get the following error:
shadow-cljs - config: /Users/jonas/Dropbox/prog/web/clojure/luminus/test/shadow-cljs.edn
shadow-cljs - running: lein with-profile +dev run -m shadow.cljs.devtools.cli --npm watch app
Executable 'lein' not found on system path.
i've looked everywhere but I cannot solve this problem. Any ideas?
update:
ok, this is what I have done to temporarily solve this:
First install in the test dir:
npm install react react-dom create-react-class
then run lein directly:
lein with-profile +dev run -m shadow.cljs.devtools.cli --npm watch app
so it is not suppose to be like this, but this is the closest that I get.
ok, I looked after a path variable to set but could not find one. So I simply copied lein from ~/bin/lein (my home dir) to /usr/local/bin and now it found it and it works.
Strange that there is no way to set this for shadow
I stareted my node app with node index.js and got the following message:
(node:10128) UnhandledPromiseRejectionWarning: TypeError: e.reduce is not a function
at Module.te (C:\Projects\myproject\node_modules\tronweb\dist\TronWeb.node.js:1:9236)
Now I'm interessted in whats happening. I've seen that there are mapping files TronWeb.node.js.map in the tronweb\dist directory. I started again using --inspect and opened the chrome dev tools. But in the console I see exactly the same message.
In Node v12.12.0+ sourcemaps are supported natively. Pass --enable-source-maps flag to enable them.
One caveat in Node v12.12.0 is that Error.prepareStackTrace will no longer be called when source maps are enabled. This was fixed in v12.16+.
You can use https://www.npmjs.com/package/source-map-support
$ npm install source-map-support --save-dev
Then change your run command in package.json to:
node -r source-map-support/register index.js
(Note that you should have an index.map.js next to index.js)
I've written a Casperjs script to do some scraping, however, after running into memory exhaustion issues, I've now written a node script to turn Phantom off and on via exec. I can run this with no issues locally, however when I deploy to heroku I get the following error
Error: Command failed: casperjs turnitoffandon.js
ERROR: stderr was:/bin/sh 1: casperjs: not found
I used the nodejs buildpack and have Phantom and Casper defined in my dependencies. In the heroku bash, running phantomjs --version returns 2.1.1 and casperjs --version returns 1.1.4.
Do I need to define where Casper is? If so how? I have set my PATH variable as /usr/local/bin:/usr/bin:/bin:/app/vendor/phantomjs/bin:/app/vendor/casperjs/bin:/node_module/casperjs/bin , like in this SO question
The issue actually had nothing to do with Heroku. As noted in this SO answer, using exec and providing any environmental variables in the options parameter replaces the entire set of environment variables. This includes the path, effectively overwriting any paths already specified to Heroku in the buildpack and npm modules.
You can create a copy of process.env and pass that along in the parameters in addition to other environmental parameters needed to be passed.
I'm trying to deploy my project on Heroku. I've been able to heroku open the app and see it but I get a 404 on my bundle.js. The app is on github here. The app is on heroku here.
I've tried making sure my dependencies are all there regarding babel, babelify, grunt, etc. But I must be still missing something.
I don't get any errors after my git push heroku but I still get my 404.
I am able to recreate this locally as well. This is what I get when I run your postinstall script code:
$ npm run postinstall
> ncps-mms#0.0.0 postinstall ncps-mms
> gulp transpile --gulpfile client/gulpfile.babel.js
[00:18:43] Requiring external module babel-register
[00:18:43] Working directory changed to ncps-mms/client
(node:30276) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
[00:18:43] Using gulpfile ncps-mms/client/gulpfile.babel.js
[00:18:44] Starting 'transpile'...
Error: Cannot find module './controllers/members-detail-controller' from 'ncps-mms/client/src'
[00:18:44] Finished 'transpile' after 184 ms
I see this error:
Error: Cannot find module './controllers/members-detail-controller' from 'ncps-mms/client/src'
The members-detail-controller is missing - See: https://github.com/gh0st/ncps-mms/tree/master/client/src/controllers.
If I comment out the following lines, https://github.com/gh0st/ncps-mms/blob/master/client/src/app.js#L4 and https://github.com/gh0st/ncps-mms/blob/master/client/src/app.js#L15 then run npm run postinstall again, the gulp tasks run without errors. I am then able to start the server without the 404's on bundle.js.
I'm familiar with debugging my own node apps (usually with node-inspector). Today I'd like to debug someone else's program. I'm trying to track down an issue with supervisor. So naturally I just add a --debug (or debug-brk) to the command call, but it passes that to the code that it is supervising.
I've tried adding debugger lines to the js file for supervisor but that didn't work (probably because no debugger was attached at that time). There's a bit of a race here -- I need to start the debugger and attach it to the supervisor process after it starts but before it processes its arguments from the command line.
What I really want to do here is stop supervisor and debug it before it processes its command line arguments. How can I do this?
I had the same problem while developing my hexo blog. The documentation isn't all that complete yet so I find myself needing to reverse engineer at times.
The basic idea is that in Node.js even your cli apps are simply normal node apps that you are exposing to the OS command line interface. On Unix systems you are using this line:
#!/usr/bin/env node
To allow the environment to execute the script.
Many cli based node apps try to insist that you install them globally with the -g option.
npm install -g node-inspector
I personally prefer to have as much control of my development environment as I can get, so I prefer to break some conventions and check my node_modules in to source control along with installing everything I can locally by dropping the -g.
npm install node-inspector
Now you don't have to do this in order to make this work, I'm just describing this setup because it relates to your question. When I run node-inspector I can't simply use:
node-inspector
Instead I must explicitly invoke it from within my project. I do this by executing the symlink in my node_modules/.bin folder:
node_modules/.bin/node-inspector
Now I'm running node-inspector just like you.
Next all I need to do is start the cli process in debug and optionally pass params to it:
node --debug-brk node_modules/.bin/hexo generate
Note I am explicitly calling the symlink here and not simply:
node --debug-brk hexo generate
If I tried the line above I would get an error: "Error: Cannot find module".
I hope this helps.