无法使用Laravel和Vue JS进行监视

时间:2019-01-30 17:45:29

标签: php node.js laravel vue.js npm

有人可以帮助我吗,我正在尝试将vue.js与laravel集成在一起,而我在尝试npm运行时却遇到问题

connect@1.0.0 development C:\xampp\htdocs\connect
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js "--watch"

The system cannot find the path specified. events.js:174
      throw er; // Unhandled 'error' event
      ^
  

错误:生成node_modules \ webpack \ bin \ webpack.js ENOENT           在notFoundError(C:\ Users \ Areg \ AppData \ Roaming \ npm \ node_modules \ cross-env \ node_modules \ cross-spawn \ lib \ enoent.js:6:26)           在verifyENOENT(C:\ Users \ Areg \ AppData \ Roaming \ npm \ node_modules \ cross-env \ node_modules \ cross-spawn \ lib \ enoent.js:40:16)           在ChildProcess.cp.emit(C:\ Users \ Areg \ AppData \ Roaming \ npm \ node_modules \ cross-env \ node_modules \ cross-spawn \ lib \ enoent.js:27:25)           在Process.ChildProcess._handle.onexit(internal / child_process.js:254:12)在以下位置引发“错误”事件:           在ChildProcess.cp.emit(C:\ Users \ Areg \ AppData \ Roaming \ npm \ node_modules \ cross-env \ node_modules \ cross-spawn \ lib \ enoent.js:30:37)

     在Process.ChildProcess._handle.onexit(内部/child_process.js:254:12)中的

npm ERR!代码ELIFECYCLE npm ERR!   errno 1 npm错误! connect@1.0.0开发:cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.j s "--watch"

这是我的包json

{
  "private": true,
  "scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "npm run development -- --watch",
    "watch-poll": "npm run watch -- --watch-poll",
    "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "devDependencies": {
    "axios": "^0.18",
    "babel-core": "^6.26.3",
    "babel-loader": "^8.0.5",
    "babel-preset-env": "^1.7.0",
    "bootstrap": "^4.0.0",
    "jquery": "^3.2",
    "laravel-mix": "^4.0.7",
    "lodash": "^4.17.5",
    "popper.js": "^1.12",
    "resolve-url-loader": "^2.3.1",
    "sass": "^1.15.2",
    "sass-loader": "^7.1.0",
    "vue": "^2.5.22",
    "vue-loader": "^15.6.2",
    "webpack": "^4.29.0"
  },
  "name": "connect",
  "description": "<p align=\"center\"><img src=\"https://laravel.com/assets/img/components/logo-laravel.svg\"></p>",
  "version": "1.0.0",
  "main": "webpack.mix.js",
  "directories": {
    "test": "tests"
  },
  "author": "Areg",
  "license": "ISC",
  "dependencies": {
    "express": "^4.16.4"
  }
}

我运行npm install并安装了所有模块,但是由于某种原因我无法运行npm watch。

2 个答案:

答案 0 :(得分:2)

尝试重新安装node_modules。也许有一些不匹配与安装的软件包和您的特定操作系统或其他一些问题。

尝试一下:

rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install

来源:Laravel Mix npm run dev error #1072

答案 1 :(得分:1)

通过运行npm run dev使其工作