0

预期行为

npm run build应该创建dist我可以在给定机器上服务的生产包

当前行为

尽管能够在本地构建,但每当我尝试npm run build在外部资源(例如 Digital Ocean VM 或 Heroku 机器)上运行时,我都会收到以下错误。

失败日志

root@nodejs-lazyq-dev:/var/www/html/Vue# npm run build

> vue-material-dashboard-pro@1.0.0 build /var/www/html/Vue
> vue-cli-service build


⠴  Building for production...

 ERROR  Failed to compile with 1 errors                                                                                                   09:29:00

 error  in ./src/assets/scss/_material-dashboard.scss

Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/lib/loader.js):

@import "md/plugins/fullCalendar";
^
      File to import not found or unreadable: md/plugins/fullCalendar.
      in /var/www/html/Vue/src/assets/scss/_material-dashboard.scss (line 59, column 1)
    at runLoaders (/var/www/html/Vue/node_modules/webpack/lib/NormalModule.js:286:20)
    at /var/www/html/Vue/node_modules/loader-runner/lib/LoaderRunner.js:364:11
    at /var/www/html/Vue/node_modules/loader-runner/lib/LoaderRunner.js:230:18
    at context.callback (/var/www/html/Vue/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at Object.asyncSassJobQueue.push [as callback] (/var/www/html/Vue/node_modules/sass-loader/lib/loader.js:55:13)
    at Object.done [as callback] (/var/www/html/Vue/node_modules/neo-async/async.js:7974:18)
    at options.error (/var/www/html/Vue/node_modules/node-sass/lib/index.js:294:32)

 @ ./src/material-dashboard.js 17:0-48
 @ ./src/main.js
 @ multi ./src/main.js

 ERROR  Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue-material-dashboard-pro@1.0.0 build: `vue-cli-service build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-material-dashboard-pro@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!     /root/.npm/_logs/2018-09-03T09_29_01_030Z-debug.log

此外,我尝试运行npm rebuild node-sass,更新material-dashboard.css文件以包含下划线:_material-dashboard.css,传入--productionnpm install --production但没有运气。

nodejs 版本:v8.11.4 npm 版本:v5.6.0

我已经尝试解决这个问题几个小时了,但没有任何运气。我不明白为什么它在本地工作,但在另一台生产机器上却不行。

4

1 回答 1

0

这是因为这个 Vue UI 库的 import 语句中的拼写错误(错误大小写)。该文件名为“fullcalendar”,而导入由“fullCalendar”调用(注意大写“C”)。当您修复此问题(在 import 语句中使大写“C”简单)时,它将成功运行“npm run prod”命令。需要注意的是,对我来说,由于某种原因,这并没有发生在windows环境中,而只是发生在Linux环境中。

于 2018-10-23T16:06:01.603 回答