Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js sh:1:rimraf:在Windows 10上安装的vagrant中运行npm run build时未找到_Node.js_Npm_Webpack_Vagrant_Windows 10 - Fatal编程技术网

Node.js sh:1:rimraf:在Windows 10上安装的vagrant中运行npm run build时未找到

Node.js sh:1:rimraf:在Windows 10上安装的vagrant中运行npm run build时未找到,node.js,npm,webpack,vagrant,windows-10,Node.js,Npm,Webpack,Vagrant,Windows 10,我想在Vagrant(安装在Windows 10上)中运行一个webpack项目,我在其中嵌入了一个Ubuntu 16.04虚拟机 我能够非常成功地安装npm5.6.0和nodejsv8.9.4 我试图运行npm install来安装我的所有依赖项。获取这些错误后: ... gyp ERR! build error gyp ERR! stack Error: `make` failed with exit code: 2 gyp ERR! stack at ChildProcess.on

我想在Vagrant(安装在Windows 10上)中运行一个webpack项目,我在其中嵌入了一个Ubuntu 16.04虚拟机

我能够非常成功地安装
npm5.6.0
nodejsv8.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安装——没有bin链接
,这给了我上面同样的错误

然后我运行:
npm运行构建

现在我不断地发现这个错误:

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,等等)上尝试了一切。没用


请帮忙

只需将此脚本添加到您的
包.json

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

当前的行为是寻找全球安装的rimraf(您也可以通过执行npm i-g rimraf来实现),但上面的一行说它应该使用本地项目的版本。

在一些罕见的情况下,
npm安装-g@angular/cli@latest
将无法在以下位置创建文件bin.js

C:\Users\{{user}}\AppData\Roaming\npm\node_modules\rimraf
因此,请运行以下命令,首先尝试创建丢失的文件

npm i -g rimraf

现在您可以运行
npm安装-g@angular/cli@latest
并且安装angular时不会出现任何问题

根据错误,您使用的是
节点v4.2.6
npm v3.5.2
,而不是
8.9.4
分别
5.6.0
。而不是
npm安装
,请尝试
npm安装--无bin链接
@Svenskunganka抱歉,我编辑了我的答案(我复制了错误的文件)。我也安装了
npm——没有bin链接
但没有成功。为什么rimraf默认情况下不能从本地
node_模块运行,就像许多其他软件包一样?@mesqueeb:也许你没有先运行
npm config set ignore scripts true来配置系统,请参阅2016年3月的回顾。