【问题标题】:Laravel getting error in npm run dev commandLaravel 在 npm run dev 命令中出现错误
【发布时间】:2018-03-25 07:11:38
【问题描述】:

我在运行时遇到错误

'npm 运行开发'

命令。

> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --p
rogress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js


'cross-env' is not recognized as an internal or external command,
operable program or batch file.

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "run" "watch"
npm ERR! node v6.11.4
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! @ watch: `cross-env NODE_ENV=development node_modules/webpack/bin/webpa
ck.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/
webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ watch script 'cross-env NODE_ENV=development node_modul
es/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_module
s/laravel-mix/setup/webpack.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js
--watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpac
k.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

谁能告诉我这里有什么问题? 谢谢

【问题讨论】:

标签: php node.js laravel


【解决方案1】:

首先你需要执行以下步骤

  • rm -rf 节点模块
  • rm package-lock.json yarn.lock
  • npm 缓存清除 --force
  • npm install --global cross-env
  • npm 安装

然后尝试重新启动终端并确保在运行“npm run dev”时没有使用集成终端(例如在 Visual Studio 代码上)。相反,请尝试在不同的 powershell 终端窗口上运行“npm run dev”命令。每次都为我工作。

【讨论】:

    【解决方案2】:

    升级 Laravel 应用后,我最近遇到了同样的问题。你只需要安装包:

    npm install cross-env
    

    【讨论】:

      猜你喜欢
      • 2020-11-25
      • 2017-08-20
      • 2017-12-28
      • 2021-06-16
      • 2021-11-14
      • 1970-01-01
      • 1970-01-01
      • 2019-02-22
      • 1970-01-01
      相关资源
      最近更新 更多