Unable to run packages installed using npm on VM provisioned by Chef - node.js

I provisioned my VM on AWS using Chef and installed NodeJS using the NodeJS recipe (https://github.com/redguide/nodejs). When I do a global npm install of any package, I am not able to run that package using command line. Attached the screenshot below.

My poise-javascript cookbook has node_package and javascript_execute resources to take care of all the required path munging for you.

There are two options:
1)add the /usr/local/nodejs-binary-6.3.0/bin/ to PATH variable.
Or
2)Run /usr/local/nodejs-binary-6.3.0/bin/http-server.
The npm package binaries are not added to path by default. I would prefer option 2 to keep the path unpolluted

Related

Stop EBS Linux 2 (Node.js) from trying to do npm install?

I'm trying to run a Node application on AWS Linux 2 on Elastic Beanstalk and need to install the dependencies using yarn. (My Node app causes errors if you try to use npm to install dependencies instead of yarn.)
I've already figured out how to set up a script in .platform/hooks/prebuild/ to get it to run yarn, but even though it's running the yarn installation, it still also tries to run npm install, which errors out, causing my deploy to fail.
So I need to figure out how to prevent the default npm install step from running.
(Does anyone know what file that command is run from in the AWS Linux 2 setup process? I was wondering if I could just add another script in .platform/hooks/prebuild/ that would modify that file to prevent the call to npm.)
yes, you can avoid npm install
When you deploy a node_modules directory to an Amazon Linux 2 Node.js platform version, Elastic Beanstalk assumes that you're providing your own dependency packages, and avoids installing dependencies specified in a package.json file.
source doc

Unable to install botskills command

Unable to install npm botskills command on Self-Hosted Azure agent.
Used following command to install packages get updated but when tried to check using "botskills" command it throws up and error saying botskills not available.
Screenshots
Used " npm install -g botskills#latest " to install the package where the following screenshot infers that the botskill packages have been updated.
But when tried to use the updated package it does not work
All the other supporting packages have been updated.
This issue occurs while using the Self-Hosted agent (Windows agent) only and works with no issue on local.
Steps to reproduce
1) Use any of the Microsoft Self-Hosted Agent.
2) Try installing botkskills using following command npm install -g botskills#latest
(Follow the attached screenshots)
3) Try using botskills to verify if the package is available.
I'm not sure if it is supported on a Azure agent, but this looks like a pathing issue.
On a typical machine, in powershell you can run the following to check what your path variable is set to:
$env:path.split(";")
You should typically have something like:
C:\Users\<username>\AppData\Roaming\npm as one of the paths.
For me, bot skills is at:
C:\Users\<myusername>\AppData\Roaming\npm\botskills.ps1
If you don't have that npm path in your path variable, that needs to be remedied somehow. If it's there, then you need to verify that botskills.ps1 is there.
When everything is setup correctly, you can use the following in PowerShell to find the path:
get-command botskills | select path
The error botskills not recognized is because the botskills package installation path is not in the System Environment variables PATH of you local machine. Azure pipeline agent is running as a different user (by default the NetworkService user), and the botskills package is installed by azure pipeline in a different path that unknown to system environment path.
You need to manually add the "path" to the system environment Path for the self-hosted agent machine.
You can also use --prefix to specify a custom npm package installation folder, and make sure add the path to system environment path for the self-hosted agent machine.
npm install botskills#latest -g --prefix C:\custompath\npm
Or you can add the installation path to Environment path in the powershell task using below script.
$env:Path += ";C:\path to botskills installation\npm"
Please check the answer to this thread for more information and the discussion for a similar issue here.

Making Global NPM packages available to all users on windows 2012 server

I am trying to install continues integration server. This server will pull data from GIT and it will try to build the application. Since I am using windows 2012 server, multiple users can trigger the build. For this purpose, I want to ensure all the node packages I install as admin are available to all users.
How can I:
Install node packages globally that are available to all users.
I want to use a locally hosted node registry. I don't want to use node registry.
After the installing the packages, how can I validate if all users can access the packages?
Had the same issue. Needed the CI build agent to run a global package on the CLI. Saw this post in a new feature request for system-wide npm -g for Windows.
In short:
Open an administrator level command prompt
Note the current global prefix: npm prefix -g
Set the global prefix to the CI user: npm config set prefix <C:\Users\CI_USER\AppData\Roaming\npm>
Install the needed packages: npm i -g PKG
Restore the prefix to the previous value.
For the 'Network Service' account use the folder:
C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\npm
You can add a global environment variable NODE_PATH to set the package require search path. You may see here for more.
https://gist.github.com/branneman/8048520#4-the-environment

Installing npm modules in a VM shared directory and grunt issues

I'm trying to put together a development environment and npm is causing me problems. Here is my scenario:
I have a development machine running Windows and VMWare Player. I have a Ubuntu Server VM (no UI) which is configured with Apache, PHP, NodeJS etc. As the VM has no UI I want to use the host OS for development. I set up a shared directory which in the VM is accessed as /mnt/hgfs/source/<project name>.
The problem comes when I attempt to run npm install within this directory. I see a lot of errors like Error: UNKNOWN, symlink '../requirejs/bin/r.js'. I know that my package.json file is OK because if I copy all files out of the share and into a regular unix directory (/var/www/<project name>) npm install works fine. So npm has a problem installing modules in the shared directory.
I thought I could get around this by installing the node packages globally but, for whatever reason, the GruntJS enthusiasts don't like that and it must be present locally. I then tried to create an npm link from global to local but that just results in a new error: Error: May not delete: /usr/lib/node_modules/grunt. I have full permissions on the /usr/lib/node_modules directory and all sub-directories.
I really don't want to write the entire project using a command-line text editor in the VM but it looks like I cannot have my code-base in a directory available to both the host and guest OS through VMWare.
I would very much appreciate any suggestions on how to either 1) allow npm modules to be installed in my shared directory, 2) run Grunt globally, or 3) solve the npm link error I'm seeing.
EDIT: Shortly after posting this I realised the fundamental issue here - it's not possible to create symbolic links within a VM shared directory when the host OS is Windows. As npm install uses symlinks by default it didn't work, and this is why the accepted solution does work.
Try the following:
npm install --no-bin-links
Grunt should be local since the plugins and gruntfile.js may require a certain version of Grunt in order to run your tasks. If another developer would like to run your tasks, they could just issue an npm install and they are set. (See this for more info.) grunt-cli is global which is used to run the local version of grunt

What location does Node.js needs to be installed

I am trying to setup a project to work with Grunt. I need to install Node.js for that to run. I have downloaded and installed Node.js in c:\programfiles.
However when I try running npm install in my project c:\Grunt-proj , I get an error 'npm' is not recognized as an internal or external command.
Can someone help me with where to install Node.js? I am trying to follow this tutorial-
http://24ways.org/2013/grunt-is-not-weird-and-hard/
Many thanks,
The location is fine. I also have installed it in Program Files. But if you need to run the command npm from a command prompt then you need to add it to the path of the system. In my case I have C:\Program Files\nodejs

Resources