[英]sh: 1: rimraf: not found whenever I run npm run build within vagrant installed on Windows 10
我想在嵌入了 Ubuntu 16.04 虛擬機的 Vagrant(安裝在 Windows 10 上)中運行一個 webpack 項目。
我能夠非常成功地安裝npm 5.6.0
和nodejs v8.9.4
。
我嘗試運行npm install
來安裝我所有的依賴項。 收到這些錯誤后:
...
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
...
我試過: npm install --no-bin-links
,它給了我上面同樣的錯誤。
所以我然后運行: npm run build
現在我不斷收到此錯誤:
sh: 1: rimraf: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! my-project@1.0.0 clean: `rimraf dist`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the my-project@1.0.0 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! my-project@1.0.0 build: `npm run clean && webpack`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-project@1.0.0 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
這是我的 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"
}
}
不知道該怎么辦,我迷路了。 我在谷歌(Github、SO 等)上嘗試了一切。 沒有工作。
請幫忙!
只需將此腳本添加到您的package.json
:
"scripts": {
...
"rimraf": "./node_modules/rimraf/bin.js",
}
當前的行為是尋找全局安裝的 rimraf(您也可以通過執行npm i -g rimraf
),但上面的行表示它應該使用本地項目的版本。
在極少數情況下, npm install -g @angular/cli@latest
將無法在以下位置創建文件bin.js
C:\Users\{{user}}\AppData\Roaming\npm\node_modules\rimraf
因此,首先嘗試通過運行以下命令來創建丟失的文件
npm i -g rimraf
現在你可以運行npm install -g @angular/cli@latest
它會毫無問題地安裝 angular
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.