In openshift server, we don't have root access that's why we can't install any npm package globally .
My question is how to setup and get working casperjs and phantomjs together in openshift server.
You may want to try a ready-to-use cartridge: https://github.com/daniel-sc/casperjs-cartridge
In package.json, add the modules you want to install on OpenShift for your app inside "dependencies" object:
"dependencies": {
"casperjs": "*",
"phantomjs": "*",
// other modules
}
Don't forget to commit and push the change onto OpenShift
Related
I made a React app with npm create-react-app which uses NodeJS backend. I am trying to deploy on Azure through Visual Studio Code extension.
I did not build locally but put a script in scripts object in package.json (of root folder)
"build": "cd client && npm install && npm run build"
My server.js resolves routing to the react app like this:
app.use(express.static("client/build"));
app.get("*", (req, res) => {
res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));
});
After I configure app services, resorce plans etc and deploy to app in App Service i get
Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 12.x
Found bindings for the following environments:
Windows 64-bit with Node.js 12.x
And my Files folder in App Service is empty ( has only hostingstart.html )
I tried removing node-sass and installing it again, I tried rebuilding it but nothing helps.
You could check your node-sass version first:npm ls node-sass
Have a look at Node-sass release URL.
I think you have done the right operation by removing and reinstalling your package, make sure you run these command in the root path of your project.
npm rebuild node-sass
npm update
npm uninstall node-sass
npm install node-sass
Don't forget restart your project.
I'm not very used to working with node and I'm having a nightmare installing the packages for a project.
I'm using vagrant/VirtualBox Homestead on Windows 10 for a Laravel (5.2) project. When doing npm install I've had a whole bunch errors - I can't remember them all specifically, but I'm wondering if there is some big picture issue I'm missing.
My first attempt was with a recent node node version - 12.something I think.
Then I was told that "some of those older projects used v8, I think", so I used nvm to do that and got a whole bunch of different issues. Some involved sym links, so I deleted node_modules and tried with --no-bin-links. That didn't work, and one of the errors, when I looked on SO, was down to node version, so I tried v9.0.0, which gave different problems.
How hard can it be?
I don't know enough about this frontend stuff to know if it's normal to have so much trouble, or if I have not been given sufficient information - e.g. "you absolutely need to use node version 8.1.3, with these specific other details..." or something like that.
Does anyone have any suggestions on how to get this working? The node-sass package seems to be a significant culprit in the overall failage of the installation...
Below is my package.json
{
"private": true,
"scripts": {
"prod": "gulp --production",
"dev": "gulp watch"
},
"devDependencies": {
"gulp": "^3.9.1",
"laravel-elixir": "^5.0.0",
"bootstrap-sass": "^3.0.0"
},
"dependencies": {
"node-sass": "^4.1.0"
}
}
I was heading same problem last time. Here is what I did:
Using terminal in homestead directory run command vagrant plugin install vagrant-winnfsd it will install plugin that allows you to use NFS protocol on Windows.
Edit you Homestead.yaml file like that:
folders:
- map: ~/Projects
to: /home/vagrant/code
type: "nfs"
Run command vagrant reload --provision. After that when you use secure shell - vagrant ssh you should be able to run npm install from inside you project directory.
I am working on a project and I want to use JSdoc for documentation. I have listed it in devDependencies and created a script to run it. My package.jsonlooks like:
"scripts": {
"doc": "jsdoc -c ./conf.json"
},
"devDependencies": {
"jsdoc": "^3.4.3"
}
Cloning my project on another machine and typing npm install installs jsdoc to the node_modules folder.
However, when I run npm run doc, I get a large error, the center of which is: 'jsdoc' is not recognized as an internal or external command
This is because JSdoc is installed in node_modules not my local path.
What is the best way to point npm-run commands to my locally installed modules? Also, what is the point of having dependencies such as JSdoc listed in devDependencies (thus installed in node_modules) when they can not be used from there?
Based on this question, when I try to run the suggested answer (heroku run npm run "script name") I get "bash: npm: command not found". I'm trying to trigger the script on a deployed meteor NodeJS app to Heroku (node version 4.8.2 and npm version 4.6.1). Any solutions to why?
package.json
{
"name": "admini_meteor",
"private": true,
"scripts": {
"deploy": "MONGO_URL=mongodb://52.1.130.211/cloud meteor"
},
"dependencies": {
"babel-runtime": "^6.23.0",
"bcrypt": "^1.0.2"
}
}
Procfile
web: npm run deploy
You need to add nodejs in your buildpack
And then deploy your app again! That's all!
I am no expert but I will try to give you a hint of your problem because I had the same one. Everything is in the docs you just need to read it.
So far the web process in the one taking care of running the actual app/server like here.
But also how is your project structure? Heroku detects you are developing a node project (because of package.json file in root directory) so it should install npm for you.
In my case I was developing a Laravel app, therefore, it created a PHP application without node and npm. There is a way to tell heroku you need both environments like state here
I have these dependencies specified in my package.json.
"dependencies": {
"express": "~3.4.4",
"casperjs": "*",
"phantomjs": "*"
},
When I push these onto the OpenShift server, I cannot use their commands like casperjs test.js. I get a bash: casperjs: command not found. However, I do see casperjs and phantomjs folders in the node_modules.
If I manually do an npm install casperjs in the repo folder, the command will work. I thought once I push changes to OpenShift, the builder will automatically do the npm installs for the dependencies I specified. What am I missing here?
Update: Since phantomjs is a dependency as well, I tried what was suggested here
https://blog.openshift.com/screen-scraper-as-a-service/
I installed the binary and the command phantomjs works. But when I restart my OpenShift server, the command no longer works. Do I need to add commands
cd app-root/data/
wget http://phantomjs.googlecode.com/files/phantomjs-1.8.0-linux-x86_64.tar.bz2
tar xf phantomjs-1.8.0-linux-x86_64.tar.bz2
rm phantomjs-1.8.0-linux-x86_64.tar.bz2
mv phantomjs-1.8.0-linux-x86_64/ phantomjs
to the scripts.start in package.json? I feel like I'm missing something simple here.
I created a new application and installed casperjs and phantomjs through npm. Now each of their commands will work after restarting the server. I assume the problem I has having was a bug or something misconfigured I couldn't spot.