Error: The module '../lib/cli' could not be located

As someone new to the world of JavaScript development, I'm encountering an error while working through the backbone_blueprints book. Here's the specific error message I've come across:

> <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8cffe5e1fce0e9a1eee0e3ebccbca2bda2bc">[email protected]</a> start /Users/noahc/Projects/backbone_blueprints/blog
> nodemon server.js


module.js:340
    throw err;
          ^
Error: Cannot find module '../lib/cli'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/Users/noahc/Projects/backbone_blueprints/blog/node_modules/.bin/nodemon:3:11)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

npm ERR! Darwin 14.1.0
npm ERR! argv "node" "/usr/local/bin/npm" "start"
npm ERR! node v0.10.33
npm ERR! npm  v2.1.11
npm ERR! code ELIFECYCLE
npm ERR! <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cbb8a2a6bba7aee6a9a7a4ac8bfbe5fae5fb">[email protected]</a> start: `nodemon server.js`
npm ERR! Exit status 8
npm ERR! 
npm ERR! Failed at the <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c2b1abafb2aea7efa0aeada582f2ecf3ecf2">[email protected]</a> start script 'nodemon server.js'.
npm ERR! This is most likely a problem with the simple-blog package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     nodemon server.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls simple-blog
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/noahc/Projects/backbone_blueprints/blog/npm-debug.log
☹ ~/Projects/backbone_blueprints/blog npm install                                                                   ruby-2.1.3
npm WARN package.json <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8bf8e2e6fbe7eea6e9e7e4eccbbba5baa5bb">[email protected]</a> No repository field.
npm WARN package.json <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b2c1dbdfc2ded79fd0deddd5f2829c839c82">[email protected]</a> No README data

A debug log is also available:

0 info it worked if it ends with ok 
1 verbose cli [ 'node', '/usr/local/bin/npm', 'install' ]
2 info using <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="503e203d10627e617e6161">[email protected]</a>
3 info using <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6e00010a0b2e185e405f5e405d5d">[email protected]</a>
4 verbose node symlink /usr/local/bin/node
5 error install Couldn't read dependencies
6 verbose stack Error: ENOENT, open '/Users/noahc/Projects/backbone_blueprints/package.json'
7 verbose cwd /Users/noahc/Projects/backbone_blueprints
8 error Darwin 14.1.0
9 error argv "node" "/usr/local/bin/npm" "install"
10 error node v0.10.33
11 error npm  v2.1.11
12 error path /Users/noahc/Projects/backbone_blueprints/package.json
13 error code ENOPACKAGEJSON
14 error errno 34 
15 error package.json ENOENT, open '/Users/noahc/Projects/backbone_blueprints/package.json'
15 error package.json This is most likely not a problem with npm itself.
15 error package.json npm can't find a package.json file in your current directory.
16 verbose exit [ 34, true ]

In addition, when checking for node and npm paths, I found the following:

☹ ~/Projects/backbone_blueprints/blog which node                                                                    ruby-2.1.3
/usr/local/bin/node
☺ ~/Projects/backbone_blueprints/blog which npm                                                                     ruby-2.1.3
/usr/local/bin/npm

I speculated that the issue could be related to a path problem. As a result, I tried adding

export NODE_PATH=/opt/lib/node_modules
to my .zshrc file and sourced it, but saw no change in the outcome.

If you have any insights on how I can troubleshoot this issue or gain a better understanding of what's happening, I would greatly appreciate it.

Answer №1

To resolve the issue, I opted to remove the folder /node_modules/ and then conduct a clean installation by running npm install.

Answer №2

Nodedemon is having trouble locating its ../lib/cli folder within its own directory. It seems like your installation might be corrupted, which can occur when using finder to move a project from one location to another.

To resolve this issue, try deleting the node_modules directory and then performing a fresh reinstallation to restore the folder:

cd your_project_folder
rm -rf node_modules
npm install

Note:

You could also consider using yarn as an alternative method:

cd your_project_folder
rm -rf node_modules
yarn

Answer №3

My experience with npm was problematic, which may have been caused by running it with sudo previously.

To resolve the issue, I had to address brew and perform an upgrade/update process

brew uninstall node
sudo chown -R $(whoami) /usr/local/*
brew cleanup
brew install node

Answer №4

After some troubleshooting, I finally discovered the solution. It turns out that nodemon needed to be installed globally using the following command: npm install nodemon -g

Answer №5

Encountered an error recently, sharing my experience here in case it can benefit someone else.

After installing yarn, I somehow caused issues with my node installation. In an attempt to rectify the situation, I started uninstalling components which only made things worse. Despite attempting to install node via Brew, it was unsuccessful due to potential compatibility issues with my outdated operating system. Manually installing from source code also did not resolve the issue with npm functionality.

Even running the command

npm -v

resulted in an error (indicating that the problem was not related to node_modules).

I ultimately resolved the issue by installing node using a package manager available here.

Answer №6

When working on macOS Big Sur, my first task was to tidy up the node modules folder:

sudo rm -rf /usr/local/lib/node_modules

Keep in mind: I had to use sudo because some folders required special permissions to delete them.

Once I removed the node_modules, I reinstalled npm package using:

brew postinstall node

Finally, npm was up and running again on my Mac:

npm -v
7.21.1

Answer №7

One possible solution would be to take the following actions:

npm remove nodemon
npm add nodemon

Answer №8

Whenever npm creates a symbolic link, it connects modules with executable declarations in the package.json file to the node_modules/.bin directory.

To learn more, check out npm's documentation.

For additional insights, read what Dr. Axel Rauschmayer has to say here.

If you happen to copy the project directory and its node_modules folder using macOS Finder, Windows File Explorer, or command line, this symbolic link gets destroyed. As a result, calls to the linked file in the node_modules/.bin directory won't reach the intended package.

In your specific scenario involving nodemon, you can manually fix this issue by running:

ln -s ./node_modules/nodemon/bin/nodemon.js ./node_modules/.bin/nodemon

For other packages, locate the "bin": { } key in their package.json files to find the symlinked executable. Modify the link command above accordingly and execute it as needed.

Answer №9

Removing node using brew
Updating brew 
Installing the latest version of node using brew
Linking node again with the overwrite option 
Checking npm version

This solution worked perfectly for my situation.

Answer №10

Running the command 'brew link --overwrite node' is sufficient, there is no requirement to uninstall anything.

This single line of code should do the trick!

Answer №11

Encountered a similar issue.

I found success using protractor --elementExplorer in resolving it.

Answer №12

There has been a change in the location of Protractor files. The lib/built Protractor files are now located in the built directory of the package. You can simply direct your IDE to built/cli.js for easy access.

If you need more information, you can visit their Github Issue link:

https://github.com/angular/protractor/issues/3089

Answer №13

After encountering the same issue post installation of nodejs using homebrew, I decided to resolve it by downloading and installing nodejs from its official website. The problem has been successfully resolved and everything is running smoothly now.

Answer №14

Encountered an issue while creating a docker image with the following line RUN apt install -g serve Resolved it by modifying the process to

RUN  curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
ENV NVM_DIR=/root/.nvm
RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" &&  nvm use v${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION}
RUN cp /root/.nvm/versions/node/v${NODE_VERSION}/bin/node /usr/bin/
RUN cp /root/.nvm/versions/node/v${NODE_VERSION}/bin/npm /usr/bin/
RUN /root/.nvm/versions/node/v${NODE_VERSION}/bin/npm install  serve -g

Answer №15

After attempting several methods outlined here, excluding yarn and brew, none seemed to solve the issue for me. However, what ultimately worked was:

curl -qL https://www.npmjs.com/install.sh | sudo sh

Magically, everything was back to normal!

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

Insert a hyperlink button using InnerHtml

I am facing an issue with displaying a list item that contains a tab and a link button: <li runat="server" id="liActivityInvoices"><a href="#tabActivityInvoices">Invoices</a><asp:LinkButton runat="server" ID="btnLoadInvoice" OnClick=" ...

Enhancing a component with injected props by including type definitions in a higher-order component

Implementing a "higher order component" without types can be achieved as shown below: const Themeable = (mapThemeToProps) => { return (WrappedComponent) => { const themedComponent = (props, { theme: appTheme }) => { return <Wrapped ...

Check for length validation including spaces in JavaScript

My code includes a functionality that calculates the length of characters in a text area using both JSP and JavaScript: <textarea class="textAreaLarge" id="citation" rows="20" cols="180" name="citation" ...

Issues with rendering Google Maps on google-maps-react persists, stuck endlessly in loading phase

After following the tutorial for google-maps-react, I attempted to display a Google Map in my app using the same structure as the example. However, the map is not rendering. Link to Tutorial There are no errors showing up in my console. Here is the dire ...

Navigating through complex immutable entities

I am having trouble working with multidimensional immutable arrays. I would like to make my array immutable, but I'm not sure how to do so. Consider the following data structure: // data { // item { name: someName, todos: [ ...

Issue encountered with the Selenium JavaScript Chrome WebDriver

When it comes to testing an application, I always rely on using Selenium chromewebdriver. For beginners like me, the starting point was following this insightful Tutorial: https://code.google.com/p/selenium/wiki/WebDriverJs#Getting_Started After download ...

Oops! An uncaught exception error occurred because the primordials were not defined

I used npm to install the package called aws-s3-zipper, but now I am encountering an error. This is the code snippet causing the issue: AWS = require("aws-sdk"); var S3Zipper = require("aws-s3-zipper"); function zipFolderOnS3() { var zipper = new S3 ...

Deletion of component with setTimeout in React Class Component

I have a notification feature that disappears after a certain delay when rendered. The issue arises when attempting to cancel this automatic removal using clearTimeout, as it doesn't seem to work. See below class Notify extends React.Component { ...

An introduction to utilizing .keypress() in jquery

I'm exploring the use of .keypress() to allow users to press enter and trigger a button click on my modal (which closes the modal). When I initially code it as: $(document).keypress(function () { console.log('keypress'); }); it works, but ...

The parameter in a JavaScript for loop

I'm struggling with my Javascript skills. Here is the code snippet I am currently working with: var information = [ {"Column":"","keyw":"","Column_3":"day of march 2011 to someother numeric" ...

Modifying the position of an HTML element within its parent tag using document.createElement

As I dive into learning Javascript, I've come across document.createElement. This method allows me to create an HTML tag and insert it into an existing HTML parent element. However, I have a specific question in mind: Is it possible to choose the exac ...

Using JSON data to render images onto a canvas

I am encountering an issue with a JSON array that I'm receiving from PHP. The array is indexed and has the following format (larger in real scenario) [ [ [17, 28, 1, "z"], [28, 31, 6, "b"], [8, 29, 6, "b"] ...

"Attempting to connect to REST server using angularjs $resource. Unexpectedly, the success callback does not

After attempting to set up a REST server on Nodejs and accessing it from AngularJS using $resource for the first time, I have encountered some issues... In my controller, I am trying to load a JSON object (shopping cart) upon login for existing users or c ...

The use of Buffer() is no longer recommended due to concerns regarding both security vulnerabilities and

I'm encountering an issue while trying to run a Discord bot. The code I'm using involves Buffer and it keeps generating errors specifically with this code snippet: const app = express(); app.get("/", (req,res) => { if((new Buffer(req.quer ...

Implementing expiration dates or future dates with jQuery

How can I modify this jQuery code to display an expiration date specified in months or years? For instance, I have created a Membership Card for a client that is valid for 2 years, and I would like to include an expiration date in the script. Thank you j ...

What is the process for initiating printing in a separate window?

Is there a way to modify the code below so that when I click "Print" it opens in a new window instead of redirecting and losing the original receipt? <div class="print_img"> <button onclick="myFunction()"> <div align="justify ...

Trigger an animation function with JQuery once the first one has finished

I am attempting to create a step-by-step animation of a div in JQuery. Each animation is triggered by a click, followed by a double-click, and so on. My issue arises when the animations overlap. When I double-click the div, both the first and second anima ...

Animating a dotted border path in SVG for a progress bar effect

I am attempting to create an animation for a dotted SVG circle that resembles a progress bar, where it fills itself over a duration of 3 seconds. However, I am facing difficulties in achieving this effect with the dotted border. The current code I have doe ...

Changing a d3 event from JavaScript to Typescript in an Angular2 environment

I am a beginner in Typescript and Angular 2. My goal is to create an Angular2 component that incorporates a d3js tool click here. However, I am facing challenges when it comes to converting it to Typescript. For instance, I am unsure if this code rewrite ...

Move on to the following iteration within a (Typescript) .forEach loop by using setTimeout

Within my array, I have a list of image URLs that I need to update the src attribute of an img tag every 10 seconds. To achieve this, I am using a forEach loop which includes a setTimeout function that calls a DOM manipulation function (replaceImage) as sh ...