The command express is not recognized in the current shell

Encountering a strange error while attempting to install the express-generator with and without using sudo.

The necessary commands are: npm install express-generator -g followed by express --ejs name_here. However, upon executing the first command, the following error is displayed:

npm ERR! Darwin 15.2.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "express-generator" "-g"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3
npm ERR! path /Users/[name]/.npm/lib/node_modules/express-generator/LICENSE
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, unlink '/Users/[name]/.npm/lib/node_modules/express-generator/LICENSE'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES, unlink '/Users/[name]/.npm/lib/node_modules/express-generator/LICENSE']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/Users/[name]/.npm/lib/node_modules/express-generator/LICENSE' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.
npm ERR! error rolling back Error: EACCES, unlink '/Users/[name]/.npm/lib/node_modules/express-generator/LICENSE'
npm ERR! error rolling back     at Error (native)
npm ERR! error rolling back  { [Error: EACCES, unlink '/Users/[name]/.npm/lib/node_modules/express-generator/LICENSE']
npm ERR! error rolling back   errno: -13,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/Users/[name]/.npm/lib/node_modules/express-generator/LICENSE' }

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/[name]/Documents/Projects/MEAN Stack Tutorial/npm-debug.log

When attempting

sudo npm install express-generator -g
, the output is as follows:

/Users/[name]/.npm/bin/express -> /Users/[name]/.npm/lib/node_modules/express-generator/bin/express
<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e5809d9597809696c882808b809784918a97a5d1cbd4d6cbd4">[email protected]</a> /Users/[name]/.npm/lib/node_modules/express-generator
├── <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a1d2ced3d5c4c58ccec3cbc4c2d5e1908f918f91">[email protected]</a>
├── <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3a595557575b545e5f487a08140d140b">[email protected]</a> (<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="76110417151310031a5b041317121a1a5914171b17161bf40815184155181817141">[email protected]</a>)
└── <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9ff2f4fbf6edefdfafb1aab1ae">[email protected]</a> (<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="adc0c4c3c4c0c4ded9ed9d839d8395">[email protected]</a>)

However, trying to run express --ejs name_here results in

-bash: express: command not found

How can I resolve this issue? Other similar queries on SO suggest using sudo, but that hasn't worked for me so far.

Answer №1

One possible solution is to execute the express command using its full path: /Users/[name]/.npm/bin/express or

sudo /Users/[name]/.npm/bin/express
.

It seems that the PATH variable was not properly configured after the installation process. For more information on the PATH variable, visit this link: (https://en.wikipedia.org/wiki/PATH_(variable))

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

Tips for ensuring an HTML element remains within defined boundaries

Currently working on a visualization tool for search algorithms using React, I've encountered a minor issue when moving the start or end nodes. Upon clicking and dragging the mouse across the grid, the nodes adjust accordingly until reaching the grid& ...

Navigating arrays containing arrays/objects and updating properties in Angular using loops

My challenge involves an array containing arrays and objects. Within a function, I am attempting to assign a value to a specific property (for example, setting 'call' of $scope.companies[0].users to the value selected in a checkbox). Despite my r ...

Enhance your MUI treeview by incorporating stylish connecting borders

I've been trying to add borders that connect to the nodes in the mui treeview, but I'm having difficulty with not having a vertical border when it's the last leaf node. It currently looks like this: See border example here. However, it sh ...

What are the drawbacks of using JavaScript to load a series of images?

Currently, I am facing an issue with the loading speed of a sequence of images on my website. The javascript code I have implemented to cycle through 50 images works perfectly fine locally but becomes slow and buggy when the site is live. Despite the image ...

Encountering issues with establishing a MongoDB connection in Node.js 8

Nodejs : v8.11.3 - mongo : v3.6.3 Referencing the tutorial found at http://mongodb.github.io/node-mongodb-native/3.0/tutorials/crud/ app.js const mongoDB = require('./common_mongo.js') mongoDB.initMongo() common_mongo.js const MongoClient = ...

Using JavaScript closures together with a timeout in the onKeyUp event

My goal is to add an onKeyUp event to all input fields within a form using closures. The array fields holds the names of the fields that need this event, while the array ajaxFields contains the names of fields requiring ajax validation. function createEve ...

Tips for managing CSS/style conflicts in JavaScript/AngularJS applications

I am new to AngularJS and I have a requirement to assign CSS properties to a component at the JavaScript file level. When I debug my code after applying the CSS styles to the component, I can see that all the applied CSS properties are behaving as expected ...

Having trouble retrieving the elements from the JSON array defined in EJS within the JavaScript script tags

<div> let arrayData='<%= myJsonArray %>' <!--myJsonArray is passed to this ejs file via the render function in index.js when rendering this ejs file --> </div> <script> let index=0; function getData(){ c ...

What is the method for inserting an icon using createElement?

Can someone help me figure out how to create a Material-UI icon using JavaScript? I am currently using the Material-UI-icon library. import ThumbUpIcon from '@material-ui/icons/ThumbUp'; var thumbsup = document.createElement(ThumbUpIcon); Any ...

Is it feasible to generate multiple app.get requests with express.js using a for loop?

Hey there, looking for some assistance since this is my first post here. I'm currently working on my main.js file and trying to figure out an easier way to do things like this: var pages = { "/profile":{"page":"My Profile","loc":"./contentPages/prof ...

Is there a way to clear the form after submitting in Rails with jQuery?

After searching extensively, I still can't find a solution. How can I clear the input fields and reset the form after submitting it? Upon clicking "Submit" with a valid email input, the form resets and the 'POST' action is triggered. Howeve ...

How can I utilize a filter or pipe to populate product categories onto screens within Ionic 2?

I am considering creating an Ionic 2 app with 6 pages, but I'm unsure whether to utilize a Pipe or a Filter for the individual category pages and how to implement the necessary code. Each category page should be able to display products from the "app ...

What steps are needed to activate the next and previous buttons in the bootstrap carousel?

Recently, I've taken an interest in using Bootstrap 5 for the design of my website. I wanted to incorporate a carousel for showcasing my coffee products, with only 3 items visible at a time when the navigation buttons are clicked. Currently, the caro ...

When the "disabled" property is enabled, the <Select> element prevents the scrollbar from appearing

I've encountered an issue where disabling a "select" element also disables the scrollbar in Internet Explorer, while it functions perfectly in Chrome and Firefox. Is there a workaround for this problem? <select size="5" style="height:100px" disa ...

Using React, retrieving the value of a checked radio button from the state

My issue involves a list of radio buttons generated from a map loop containing numbers like 1, 2, and 3. When I select a radio button, it should set a state: <ul className="flex gap-6 justify-center"> {maxPaxArr.map((keypax) => ...

What is the best way to manage and add dates in my database using Node.JS and MongoDB?

I am currently developing a Calendar application using Node.JS and MongoDB. However, I am encountering difficulties when trying to integrate data from the database into the existing calendar system. Whenever I attempt to load LocalHost:3000/init, I am pre ...

What characteristics do you use to distinguish a non-compiled language?

Curiosity strikes me as I notice a common theme of "personal preference" regarding the distinctions between "Scripting Language" and "Programming Language". Here is my query: Is there a specific technical term for a language that operates without the nee ...

Transforming JavaScript/Angular 1 from using Promise.all to async-await technique

Within the $onInit() function, I set two web service calls to run concurrently and store their responses in variables named referencesPromise and contactTypesPromise. If necessary, a new method can be created for this purpose. $onInit() { const referenc ...

Where should JSON data be sourced from when developing a service in AngularJS?

Just starting out with Angular! Am I correct in assuming that when creating a service, you request JSON data from a server controlled by someone else? For example, if I wanted to develop a Weather app, where could I find the JSON data? Is there a standar ...

Deleting empty tags in an HTML h1 element with JavaScript

Is there a way to use JavaScript to remove empty h1 tags only? <h1>Hello World!</h1> <p>Lorem ipsum dolor sit amet</p> <h1></h1> <p>consectetur adipiscing elit.</p> <h1></h1> <p>Sed do ...