为什么我无法运行 Npm run dev?

问题描述 投票:0回答:6

伙计们,你们能帮我解决这个问题吗?我在为我的 Laravel Mix 运行 npm run dev 时遇到问题。我点击了下面的链接,但仍然存在错误。我的操作系统有问题吗?我尝试删除node_modules,运行npm install --global cross-env。并再次运行 NPM install。

“cross-env”不被识别为内部或外部命令,

https://github.com/JeffreyWay/laravel-mix/issues/478

我运行时总是遇到的错误

npm run dev

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ development 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!     /Users/baloghdominik/.npm/_logs/2020-02-26T17_05_54_290Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ dev 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!     /Users/baloghdominik/.npm/_logs/2020-02-26T17_05_54_315Z-debug.log
npm npm-install laravel-mix
6个回答
18
投票

首次运行

npm install cross-env

npm install 

然后运行

npm run dev

6
投票

简单步骤:

  1. npm 缓存清除--force
  2. 删除node_modules和package-lock.json
  3. npm 安装
  4. npm 运行开发

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

基本上删除node_modules文件夹和package-lock.json文件,清除缓存并执行npm安装。为我工作。


0
投票

就我而言,我有旧版本的node.js 所以我刚刚安装了我需要的版本:

sudo npm install n -g

sudo n stable

或者可以尝试使用最新的:

sudo n latest


0
投票

如果您使用

nvm
,您需要使用项目版本。命令对我有帮助:

  1. 使用默认版本节点:
    nvm use system
  2. 删除node_modules
    rm -rf node_modules
    rm -f package-lock.json
  3. 清除缓存
    npm cache clear --force
  4. 命令完成
    npm i

0
投票

就我而言,我尝试运行 Next.js 项目版本 13.5.6,但遇到了以下错误:

Watching /Users/moysantanav/Documents/Projects/BuhoHubWeb and all sub-directories not excluded by your .gitignore. Will not monitor dotfiles.
Found & ignored ./node_modules ; is listed in .gitignore
Found & ignored ./src/app/clientFiles/[id]/clientInfo.module.css ; has ignored extension
Found & ignored ./src/app/clientFiles/clientFiles.module.css ; has ignored extension
Found & ignored ./src/app/globals.css ; has ignored extension
Found & ignored ./src/app/login/login.module.css ; has ignored extension
Found & ignored ./src/app/login/verticalLogin.module.css ; has ignored extension
Found & ignored ./src/app/page.module.css ; has ignored extension
Found & ignored ./src/components/appointmentCard/AppointmentCard.module.css ; has ignored extension
Found & ignored ./src/components/appointments/Appointments.module.css ; has ignored extension
Found & ignored ./src/components/calendar/Calendar.module.css ; has ignored extension
Found & ignored ./src/components/checkoutTable/checkouttable.module.css ; has ignored extension
Found & ignored ./src/components/customButton/button.module.css ; has ignored extension
Found & ignored ./src/components/customInput/input.module.css ; has ignored extension
Found & ignored ./src/components/menuServicesComponent/serviceMenu/serviceMenu.module.css ; has ignored extension
Found & ignored ./src/components/menuServicesComponent/serviceMenuTable/serviceMenuTable.module.css ; has ignored extension
Found & ignored ./src/components/modal/Modal.module.css ; has ignored extension
Found & ignored ./src/components/scheduleManagement/scheduleManagement.module.css ; has ignored extension
Found & ignored ./src/components/storeItem/storeItem.module.css ; has ignored extension
Found & ignored ./src/components/storeList/storeList.module.css ; has ignored extension

Starting: next dev
node:internal/modules/cjs/loader:1078
  throw err;
  ^

Error: Cannot find module '/Users/moysantanav/Documents/Projects/BuhoHubWeb/next'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Module._load (node:internal/modules/cjs/loader:920:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

这是修复使用

npm install cross-env

npm install 

然后运行

npm run dev
© www.soinside.com 2019 - 2024. All rights reserved.