How to setup Jenkins on Openshift to run Node.js builds? - node.js

I have a Jenkins gear instance available on my Openshift plan. I would like to build my Javascript application with Grunt, which will then be hosted on a PHP 5.4 gear.
As Node.js instance available on Jenkins'slave is outdated, I install a newer version for my builds thanks Jenkins Node.js module, which allows you to download automatically Node.js binaries from Internet in your Jenkins slave.
This works great, as I can get node and npm versions.
Here is my build script:
node --version
npm --version
which npm
npm config get prefix
And the build log:
[NodeTest] $ /bin/sh -xe /tmp/hudson493047459386546146.sh
+ node --version
v0.10.32
+ npm --version
1.4.28
+ which npm
/var/lib/openshift/542ab7f1500446fba1000081/app-root/data/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_0.10.32/bin/npm
+ npm config get prefix
/var/lib/openshift/542ab7f1500446fba1000081/app-root/data/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_0.10.32
But when I try to install a module, I get this error:
Script:
npm install grunt
Output:
npm ERR! Error: Attempt to unlock grunt, which hasn't been locked
npm ERR! at unlock (/var/lib/openshift/542ab7f1500446fba1000081/app-root/data/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/ NodeJS_0.10.32/lib/node_modules/npm/lib/utils/locker.js:44:11)
npm ERR! at cb (/var/lib/openshift/542ab7f1500446fba1000081/app-root/data/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/ NodeJS_0.10.32/lib/node_modules/npm/lib/cache/add-local.js:30:5)
...
I tried to customize npm_config_userconfig or NPM_CONFIG_PREFIX environment variables but without success.
How to install NPM modules on Jenkins on Openshift ?

Related

Error installing sveltekit app after upgrading Node to latest version

I recently upgraded node to the latest version (v16.15.1). After upgrading, I started a new sveltekit site using the following command:
npm init svelte my-app
I CD'd into my-app and ran npm install and get the following error:
npm ERR! code 127
npm ERR! path /Users/henken/Sites/my-app
npm ERR! command failed
npm ERR! command sh -c svelte-kit sync
npm ERR! sh: svelte-kit: command not found
I've created many sveltekit apps using these exact steps without any issues until today after upgrading node. Any suggestions would be much appreciated.
Remove the my-app folder and run:
npm init svelte#latest my-app
The #latest makes sure that npm uses latest version of the create-svelte package.
The version you've got cached locally could be incompatible with the current version of SvelteKit.
Alternative things to try:
Reboot PC (removes environment settings that could point to previous node installation)
Upgrade npm to latest version

npm ERR! cb.apply is not a function (Elementary OS)

I am very new to react native and nodejs . Today I installed nodejs on my Elementary Os and installed npm and npx. Now when I try to run npx create-react-app myApp i am getting the following error :
npm ERR! cb.apply is not a function npm ERR! A complete log of this
run can be found in: npm ERR!
/home/user/.npm/_logs/2021-04-29T08_55_29_599Z-debug.log Install for [
'create-react-project#latest' ] failed with code 1
I found some answers on stack overflow but they didn't solve this. Any help would be much appreciated.
npx version:10.2.2
npm version: 7.10.0
node version :16.0.0
I finally solved the error and i am going to keep this thread open if anyone else faces the same problem.
By default, npm installs packages in the local node_modules/ directory. Since npm i npm is shorthand for npm install npm, it will install the latest version of npm locally.
However, when run npm in a shell, the shell picks up the npm in your $PATH, which is probably the global installation.
To update the global installation of npm, run:
npm install --global npm

Plesk How to install additional modules?

i have troubles using Node Js with Plesk. I have a Root Server (Ubuntu + Plesk Onyx) and installed Node Js. My API runs well. But now I have a new API Build, and must install new Node modules. (Hummus.js) When I want to install it through my package.json I get =
Execution filemng has failed with exit code 1, stdout:
hummus#1.0.81 install /var/www/vhosts/XXX/api.XXX/node_modules/hummus
node-pre-gyp install --fallback-to-build
I think the problem is failed dependencies for Hummus.
So I want to do
npm install -g node-gyp
But how can I run it with plesk? I have only a "NPM Install" button but it run install package.json
Plesk locates npm for its node versions under /opt/plesk/node. Like /opt/plesk/node/6 or /opt/plesk/node/7 So to install modules you should run:
/opt/plesk/node/7/bin/npm install -g node-gyp

how to download node modules to Angular 2 project

I have git project downloaded in dir d:/myapp. I have npm 3.10.10 and node 6.11 install on my windows machine. But while runnning Install npm from git bash commd line to install all dependent node module...i get error as below:
$ install npm
install: missing destination file operand after 'npm'
Try 'install --help' for more information.
The command to install npm modules is just npm install. It looks you are doing install npm install, with an extra "install" before npm.
Here are the official docs for npm install showing the different options. Note that npm is always the first command for any npm commands, whether it's install, start, etc.

How to install certain node version from command line

I want to install node 6.9.4.
In windows console I try with this:
npm install node#v6.9.4
And it throws this error:
npm ERR! No compatible version found: node#v6.9.4
npm ERR! Valid install targets:
npm ERR! 0.0.0
In linux the result is similar. I try with
sudo npm install node#v6.9.4
and the output is:
npm ERR! version not found: node#6.9.4-cls
Is there a way to install certain node version with npm?
You should use nvm to install and manage node versions and not npm
NPM is the package manager for node and not a version manager.
To install a particular version of node using nvm, just do
nvm install v0.10.32
NPM should be used to install packages/modules.
So say you need to use request module for a particular project
You can do
npm install request
Both these support tons of options which could be found over the documentations
I recommend you use nvm: Nodev Version Manager
It would be as easy as
nvm install 6.9.4
It's a really good tool to manager all of your node versions.

Resources