【问题标题】:Laravel 5.8 npm run dev generating an ENOENT errorLaravel 5.8 npm run dev 生成 ENOENT 错误
【发布时间】:2021-11-25 15:14:07
【问题描述】:

我需要运行“npm run dev”来更新 Laravel 5.8 Web 应用程序中的引导程序和 jquery,但它不断生成以下错误...

(node:4758) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, lstat 'xxx/xxx/xxx/node_modules/admin-lte/bootstrap'
    at Object.lstatSync (fs.js:1115:3)
    at Object.lstatSync (xxx/xxx/xxx/node_modules/graceful-fs/polyfills.js:311:34)
    at statFunc (xxx/xxx/xxx/node_modules/fs-extra/lib/util/stat.js:24:20)
    at getStatsSync (xxx/xxx/xxx/node_modules/fs-extra/lib/util/stat.js:25:19)
    at Object.checkPathsSync (xxx/xxx/xxx/node_modules/fs-extra/lib/util/stat.js:67:33)
    at Object.copySync (xxx/xxx/xxx/node_modules/fs-extra/lib/copy-sync/copy-sync.js:24:38)
    at File.copyTo (xxx/xxx/xxx/node_modules/laravel-mix/src/File.js:245:12)
    at FileCollection.copyTo (xxx/xxx/xxx/node_modules/laravel-mix/src/FileCollection.js:83:17)
    at xxx/xxx/xxx/node_modules/laravel-mix/src/FileCollection.js:77:38
    at Array.forEach (<anonymous>)
    at FileCollection.copyTo (xxx/xxx/xxx/node_modules/laravel-mix/src/FileCollection.js:77:17)
    at CopyFilesTask.run (xxx/xxx/xxx/node_modules/laravel-mix/src/tasks/CopyFilesTask.js:16:20)
    at CustomTasksPlugin.runTask (xxx/xxx/xxx/node_modules/laravel-mix/src/webpackPlugins/CustomTasksPlugin.js:46:36)
    at CustomTasksPlugin.runTasks (xxx/xxx/xxx/node_modules/laravel-mix/src/webpackPlugins/CustomTasksPlugin.js:87:21)
    at xxx/xxx/xxx/node_modules/laravel-mix/src/webpackPlugins/CustomTasksPlugin.js:87:58
(Use `node --trace-warnings ...` to show where the warning was created)
(node:4758) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)

我的 package.json 中有以下内容...

{
  "private": true,
  "scripts": {
    "dev": "npm run development",
    "development": "mix",
    "watch": "mix watch",
    "watch-poll": "mix watch -- --watch-options--poll=1000",
    "hot": "mix watch --hot",
    "prod": "npm run production",
    "production": "mix --production"
  },
  "devDependencies": {
    "axios": "^0.16.2",
    "bootstrap-sass": "^3.4.1",
    "cross-env": "^7.0.3",
    "jquery": "^3.5.0",
    "laravel-mix": "^6.0.31",
    "lodash": "^4.17.4",
    "vue": "^2.6.14"
  },
  "dependencies": {
    "admin-lte": "^3.1.0",
    "dropzone": "^5.1.1",
    "jquery-contextmenu": "^2.6.2"
  }
} 

以及我的 webpack.mix.js 中的以下内容

let mix = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/assets/js/app.js', 'public/js').vue()

    .sass('resources/assets/sass/app.scss', 'public/css')
    
    // General CSS
    .copyDirectory('resources/assets/css', 'public/css')
    
    // Admin LTE Assets
    .copyDirectory('node_modules/admin-lte/bootstrap', 'public/admin-lte/bootstrap')
    .copyDirectory('node_modules/admin-lte/dist', 'public/admin-lte')
    .copyDirectory('node_modules/admin-lte/plugins', 'public/plugins')
    
    // Context Menu
    .copyDirectory('node_modules/jquery-contextmenu', 'public/plugins/jquery-contextmenu')
    
    // Dropzone
    .copyDirectory('node_modules/dropzone/dist', 'public/plugins/dropzone')
    
    // Images
    .copyDirectory('resources/assets/images', 'public/images');

节点版本 v14.17.7

npm 版本 6.14.15

Laravel 5.8.11

我尝试使用 php artisan cache:clear 删除缓存,然后删除节点模块文件夹,然后使用“npm install”,但似乎没有任何效果。

我猜测这些版本彼此不同步,但无法确定我需要修复什么。

【问题讨论】:

    标签: npm laravel-5.8 adminlte enoent


    【解决方案1】:

    我通过在 /node_modules/admin-lte/ 中手动创建目录“bootstrap”解决了这个问题

    mkdir node_modules/admin-lte/bootstrap/
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-31
      • 2021-04-11
      • 2015-03-12
      • 2019-01-09
      • 1970-01-01
      • 2021-04-14
      • 2020-11-25
      • 2018-03-25
      相关资源
      最近更新 更多