When I try to run npm run build in a Vagrant environment on Windows 10, I receive an error message saying "rimraf: not found"

I am attempting to run a webpack project in Vagrant (on Windows 10) with an embedded Ubuntu 16.04 virtual machine.

Successfully installed npm 5.6.0 and nodejs v8.9.4.

After running npm install for dependencies, encountered the following errors :

...
gyp ERR! build error
...more errors here...

Tried using npm install --no-bin-links, but faced similar issues.

Then attempted npm run build

Now encountering this new error :

sh: 1: rimraf: not found
...more errors here...

Here is my package.json :

{
  "name": "my-project",
  ... more JSON data ...
}

I have tried various solutions from Google search with no success. Need help, feeling lost!

Answer №1

To include this code in your package.json, simply add the following script:

"scripts": {
    ...
    "rimraf": "./node_modules/rimraf/bin.js",
}

The current functionality is searching for rimraf installed globally (which can also be done by running npm i -g rimraf), but the specified line instructs it to utilize the version within the local project.

Answer №2

If you encounter a rare issue where

npm install -g @angular/cli@latest
fails to generate the file bin.js at this specific location

C:\Users\{{user}}\AppData\Roaming\npm\node_modules\rimraf

Attempt resolving this by manually creating the missing file with the command below:

npm i -g rimraf

Afterward, proceed to execute

npm install -g @angular/cli@latest
and the installation of Angular should now proceed smoothly without any issues.

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

Solve the mystery of hidden IP addresses in Node.js with the help of the DNS module

Is it possible to achieve the same result as running the command dns-sd -q a5b3ef18-2e66-4e24-91d2-893b93bbc1c1.local on Mac OSX using Node.js? It appears that the dns module in Node.js is primarily used for converting website addresses to IP addresses, no ...

Is there a way to display the entire stack trace in Mocha when testing Promises and an error occurs?

Imagine I have a small specification like this: describe("feature", () => { it("does something", () => { return myPromiseBasedFn().then(result => { expect(result).to.eql(1); }); }); }); At the moment, when the promise is reject ...

Tell me about node-persist

During my online learning journey of Node.js on Udemy, I encountered the term node-persist. Despite searching for it on Google, I couldn't find a clear explanation. Could someone please provide a concise definition of what node-persist is? ...

Checking the validity of admin users with Passport JS

I'm currently working on a Node.js and Express application with EJS as the front end. One challenge I am facing is implementing a middleware function using Passport that needs to run before all create, edit, and delete routes. function isLoggedIn(re ...

"Encountering an Error with Socket.IO: Type M

I am facing a puzzling issue with my NodeJS server setup. The server relies on bcrypt, mysql and socket.IO to act as a bridge between a mysql database and a chat server. The communication with the client is established using Socket.IO client, with requests ...

Alert: React-Weather is causing an invalid element type in React

I am feeling overwhelmed. I have created a custom component called react-weather which has been installed using npm. Here is the code snippet for my self-written Weather.js component located in the src/components folder: import React, { Component } from & ...

Verify if the program is operating on a server or locally

My current project involves a website with a game client and a server that communicate via sockets. The issue I'm facing is how to set the socket url depending on whether the code is running on the server or my local PC. During testing and debugging, ...

Upon initializing Gridfs, a TypeError is encountered indicating that a string is not a function

My goal is to store an uploaded file, like an image, in a mongodb database. However, I keep encountering a Type Error when trying to set up the gridfs-stream. Below is my code snippet: var mongo = require('mongodb'); router.post('/createpo ...

The event handlers on all elements are not loaded when the HTML page is rendered

Currently in the process of developing a project which involves a web server app built with nodejs + express and some client views that are rendered using ejs. In the main app.js file, the following code is present: const express = require('express& ...

What are some solutions for troubleshooting a laptop freeze when running JavaScript yarn tests?

Running the yarn test command results in all 20 CPU cores being fully occupied by Node.js, causing my laptop to freeze up. This issue is particularly troubling as many NodeJS/Electron apps such as Skype, MS Teams, and Slack are killed by the operating syst ...

Is there a way to deliver information to a specific element on a client's HTML page?

My current project involves using Node.js to serve a webpage that collects user inputs and stores them in a mongodb server. The web page also displays these user inputs. I am trying to determine the best way to pass the user inputs from node.js to the < ...

Encountering issues with resolving dependencies in webdriverIO

I'm attempting to execute my WebdriverIo Specs using (npm run test-local) and encountering an error even though I have all the necessary dependencies listed in my package.json as shown below: [0-2] Error: Failed to create a session. Error forwardin ...

What steps are involved in uploading a package to npm with an API key?

NPM offers the option to generate access tokens that grant permission to publish packages to the NPM registry. To utilize this feature, you need to configure your package settings to "Require two-factor authentication or automation tokens" under "Publishin ...

Encountering issue with npm installing incorrect version of angular-cli

I need to install a specific version of Angular, specifically 8.3.19. To do so, I executed the command npm install -g @angular/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5f3c33361f67716c716e66">[email protected]< ...

Javascript Library Issue: "Implicitly Declared Type 'Any' Error"

I am currently in the process of developing a JavaScript library that will interact with an API. My goal is to create a module that can be easily published on npm and utilized across various frameworks such as Angular or React. Below is the code snippet fo ...

Is it possible for npm install to disregard development dependencies during the installation process

In a Node.js project, running npm install will install both the dependencies and dev dependencies. To skip installing dev dependencies, you can use npm install --production. Question 1: If I don't include --production, will the dependencies' dev ...

Using nodejs streams to compress a file with gzip can lead to memory drain

I'm attempting to perform a seemingly simple task: take a file named X and create a gzipped version called "X.gz". Since Node.js's zlib module lacks a straightforward zlib.gzip(infile, outfile) function, I decided to use input and output streams ...

Managing ajax requests, failing to retrieve information

I am struggling to configure my client-side ajax calls to send data to a node express server. I want the ajax request to be triggered "onclick" of an href link. My goal is to pass the ID of the link as a variable to the server, but unfortunately, the serv ...

Comparing Express.js View Engine to Manual Compilation

Currently, I am utilizing Express.js along with the hbs library to incorporate Handlebars templates in my application. Lately, I've delved into establishing a build system using gulp for my app and stumbled upon packages like gulp-handlebars. My query ...

Why is my JSON object showing up as undefined in my Node.js POST request?

I have a CentOS server that is currently running a node.js HTTP server (code provided below). My goal is to pass JSON data from the command line by using the following CURL command: curl -X POST -H "application/json" -d '{"val1":"hello","val2":"my"," ...