Error: Command not recognized for the npm packages that were installed

After successfully installing a npm package locally, I used npm list --depth=0 to confirm its installation. However, when trying to run any command from that package in the terminal, I kept getting the error message:

zsh: command not found: <command name>

I consulted a Stack Overflow thread and followed the advice of adding

source /Users/YOURSERNAME/.bash_profile
at the start of my ~/.zshrc file. Despite doing so, the issue persisted. Occasionally, I also encountered an error indicating that
no such file or directory:/Users/YOURSERNAME/.bash_profile
. Are there any other troubleshooting steps I should take?

Answer №1

Insert the following code snippet into your .zshrc configuration file:

NPM_PACKAGES="${HOME}/.npm-packages"
export PATH="$PATH:$NPM_PACKAGES/bin"
# If MANPATH is already defined, keep it as is. Otherwise, use `manpath`.
export MANPATH="${MANPATH-$(manpath)}:$NPM_PACKAGES/share/man"

Originally sourced from: https://dev.to/rrampage/5-npm-and-node-tips-to-make-your-machine-safer-3g0l

Remember to reload your zsh settings afterwards:

source ~/.zshrc

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What steps are required to generate dist/app.js from a script file in my TypeScript project?

I am currently working on a project using node, express, and TypeScript. When I run npm run build, everything builds without any issues. However, when I attempt to run npm run start, I encounter the following error: @ruler-mobility/[email protected] /User ...

Utilizing NPM Workspace Project in conjunction with Vite to eliminate the necessity of the dist folder during the Vite build process

I am currently working on a project that involves a module using full path exports instead of index files. This project is divided into 2 NPM workspaces: one called core and the other called examples. The challenge I am facing is avoiding long import pat ...

Jenkins is left in a state of paralysis as the npm command fails to yield back control to

When using Jenkins to remotely execute a shell command in Linux, the following command is used: npm run develop However, it appears that this command does not return to the terminal as expected, displaying various project information instead. To run the ...

Step-by-step guide to integrating VS Code Debug with Foreman and running `nf start`

I have implemented this Heroku project as the foundation for a Node cluster environment. https://github.com/heroku-examples/node-workers-example However, as it utilizes foreman to initiate multiple processes upon start, I am facing difficulty in connecti ...

Building a Node/React application and packaging it for Linux using pkg

I am in the process of converting a node/react application into a native executable for Mac, Windows, and Linux using 'pkg' (check it out on https://github.com/zeit/pkg/). The application runs smoothly with node on my machine. I successfully bui ...

Encountering node-gyp errors while running React-Native npm i

After working smoothly on a project for a while without any environmental issues, I had to relocate the project to a different directory. Upon deleting and cloning it elsewhere, problems arose. Attempting to run npm install resulted in an error related t ...

What steps do I need to follow to successfully run a node.js application that was installed using npm?

After successfully installing Node.js on my Windows machine, I proceeded to the command prompt and entered: npm ethercalc A flurry of lines appeared as ethercalc and its dependencies were being downloaded and installed. Now the question is, how do I actu ...

Having trouble transitioning to Angular2 RC? Let's chat at [email protected] - we can help!

I encountered an error while attempting to upgrade angular2 to RC. Due to JWT dependencies on RC, I had to switch to @angular. M:\workspace\Angular2StartKit>npm install npm ERR! addLocal Could not install M:\workspace\Angular2StartK ...

Encountering a 403 error while attempting to publish a scoped package

As the proud developer behind the frs-replace package, I wanted to share some exciting news. After some discussions and deliberations, I have decided to transfer the package under a new organization's umbrella (frsource). To facilitate this, I have e ...

"Experimenting with Protractor by launching a browser in the main directory of XAMPP server

Currently, I am attempting to run an end-to-end test following the instructions on the Angular website: https://docs.angularjs.org/tutorial/step_03 However, when I execute npm run protractor in git bash, everything proceeds smoothly except for one issue ...

Error in Angular 2: Component unable to locate imported module

I'm facing an issue where a module I want to use in my application cannot be found. The error message I receive is: GET http://product-admin.dev/node_modules/angular2-toaster/ 404 (Not Found) The module was installed via NPM and its Github reposito ...

The Laravel app on Heroku was unable to locate the Vite manifest file at the specified directory: /app/public/build/manifest

My Laravel project uploaded on Heroku is showing the error message "Vite manifest not found at: /app/public/build/manifest.json" It was running perfectly on localhost, but now it's not working on Heroku. This link provides a preview of the issue: I ...

Guide for Setting Up Ursa on Your Ubuntu System

I am attempting to set up Ursa on my Ubuntu machine but encountering an issue. The version of Node.js I am using is: - node -v v10.4.1 - node-gyp -v v3.6.2 Despite checking the error stack, I am unable to pinpoint the cause of the problem: gyp E ...

Bower is not a valid internal or external command on this computer

I've encountered a common issue that many have asked about before, but I still haven't found a solution. I'm using windows 10 and managed to install bower through npm with this command: npm install -g bower Even though I added the path to ...

Having trouble shutting down Metro Bundler on Windows?

While working on my React Native development, I regularly use npm start to get things going. However, I've run into an issue recently when trying to stop the process using Ctrl + c. It seems like I can no longer use npm start smoothly: ERROR Metro ...

Difficulty with setting up Typescript in Visual Studio Code on MacOS Catalina

I'm currently facing an issue that appears to be related to the environment. How can I resolve it? And how do I link the installed TSC to my console? Steps to Recreate: npm install -g typescript was able to successfully install or update [email ...

The bootstrap4 UI Framework Web project encountered an npm run build error

Hey, I'm in need of some assistance. Whenever I enter npm run build into my Windows 10 terminal, I encounter the following errors: 'imagemin' is not recognized as an internal or external command, operable program, or batch file. npm ER ...

Unable to define a variable in the Time Picker package of React Native npm

Using a react native Time picker for the date component is causing an issue. After updating the time with it, there seems to be a failure in getting and saving the time in the variable (cdate). Properties constructor (props) { super(props); ...

I encountered an error while trying to install image-webpack-loader using NPM. This setback is preventing me from continuing with my project

I had no issues with Webpack all day until I added a new image, then it suddenly stopped working. Even after updating node and npm, I'm still getting the same error message. How can I resolve this problem or find an alternative solution? The other ima ...

Experiencing difficulties when integrating the pdf-viewer-reactjs module within Next.js framework

I recently integrated the pdf-viewer-reactjs library into my Next.js project and encountered the following error: error - ./node_modules/pdfjs-dist/build/pdf.js 2094:26 Module parse failed: Unexpected token (2094:26) You may need an appropriate loader to h ...