26

I want to run a webpack project within Vagrant (installed on Windows 10) where I embedded a Ubuntu 16.04 virtual machine.

I was able to install npm 5.6.0 and nodejs v8.9.4 very successfully.

I tried to run npm install to install all my dependencies. After getting these errors :

...
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 4.4.0-116-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /vagrant/src/my_project/static/node_modules/contextify
gyp ERR! node -v v8.9.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
...

I tried : npm install --no-bin-links, which gave me the same kind of erros above.

So I then run : npm run build

And now I keep getting this error :

sh: 1: rimraf: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] clean: `rimraf dist`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] clean script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2018-03-04T04_44_09_988Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `npm run clean && webpack`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2018-03-04T04_44_10_048Z-debug.log

Here is my package.json :

{
  "name": "my-project",
  "version": "1.0.0",
  "description": "project",
  "main": "index.js",
  "scripts": {
    "clean": "rimraf dist",
    "build": "npm run clean && webpack",
    "serve": "webpack-dev-server"
  },
  "repository": "",
  "author": "Edgar KAMDEM",
  "license": "ISC",
  "dependencies": {
    "acorn": "^5.5.0",
    "axios": "^0.17.1",
    "bootstrap": "^4.0.0-alpha.6",
    "fabric": "^1.7.22",
    "file-loader": "^1.1.5",
    "font-awesome": "^4.7.0",
    "jquery": "^3.2.1",
    "jquery-ui-dist": "^1.12.1",
    "lodash": "^4.17.4",
    "mxgraph": "^3.8.0",
    "popper.js": "^1.12.9",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-input-range": "^1.2.2",
    "react-redux": "^5.0.6",
    "react-router": "^4.2.0",
    "react-router-dom": "^4.2.2",
    "redux": "^3.7.2",
    "redux-form": "^7.2.0",
    "redux-promise": "^0.5.3",
    "redux-thunk": "^2.2.0"
  },
  "devDependencies": {
    "autoprefixer": "^7.1.6",
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.2",
    "css-loader": "^0.28.7",
    "extract-text-webpack-plugin": "^3.0.2",
    "html-webpack-plugin": "^2.30.1",
    "node-sass": "^4.7.2",
    "postcss-loader": "^2.0.9",
    "precss": "^2.0.0",
    "rimraf": "^2.6.2",
    "sass-loader": "^6.0.6",
    "style-loader": "^0.19.0",
    "webpack": "^3.11.0",
    "webpack-dev-server": "^2.11.2"
  }
}

Don't know what to do, I'm lost. I tried everything on Google (Github, SO etc). Nothing work.

Please help!

3
  • According to the errors, you're using node v4.2.6 and npm v3.5.2, not 8.9.4 respectively 5.6.0.
    – Sven
    Mar 4, 2018 at 5:04
  • Instead of npm install, try with npm install --no-bin-links.
    – Sven
    Mar 4, 2018 at 5:09
  • @Svenskunganka sorry I edited my answer (I copied the wrong file). I also did npm install --no-bin-links with no success
    – kabrice
    Mar 4, 2018 at 5:18

2 Answers 2

21

Just add this script to your package.json:

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

The current behavior is looking for globally installed rimraf (you can do it as well by executing npm i -g rimraf), but the line above says it should use local project's version.

2
  • 10
    how come rimraf cannot be run from local node_modules by default, like so many other packages can?
    – mesqueeb
    Dec 19, 2020 at 4:38
  • @mesqueeb: perhaps you have missed to configure your system first by running npm config set ignore-scripts true, see Package install scripts vulnerability back from March 2016.
    – hakre
    Feb 11, 2021 at 23:09
10

In some rare cases, npm install -g @angular/cli@latest will fail to create the file bin.js in the following location

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

So try creating the missed file first by running the following command

npm i -g rimraf

Now you can run npm install -g @angular/cli@latest and it will install angular without any problems

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.