简体   繁体   English

无法在生产中使用vue-cli调用npm run build

[英]Unable to call npm run build using vue-cli in production

Expected Behavior 预期行为

npm run build should create the production dist bundle that I can serve on a given machine npm run build应该创建我可以在给定机器上使用的生产dist

Current Behavior 当前行为

Despite being able to build locally, whenever I try to run npm run build on an external resource (such as a Digital Ocean VM or Heroku machine), I receive the below error. 尽管能够在本地构建,但是每当我尝试在外部资源(例如Digital Ocean VM或Heroku机器)上运行npm run build时,我都会收到以下错误。

Failure Logs 故障记录

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

Additionally, I have tried running npm rebuild node-sass , updated the material-dashboard.css file to include the underscore: _material-dashboard.css , passing --production in npm install --production , but am having no luck. 另外,我尝试运行npm rebuild node-sass ,更新了material-dashboard.css文件以包括下划线: _material-dashboard.css ,在npm install --production传递--production npm install --production ,但是没有运气。

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

I've been trying to solve this for a few hours now but am not having any luck. 我已经尝试解决了几个小时,但是没有任何运气。 I don't understand why it works locally but not when on another production machine. 我不明白为什么它会在本地运行,但在其他生产机器上却无法运行。

This happens because of a spelling mistake (wrong case) in the import statement of this Vue UI library. 发生这种情况是因为该Vue UI库的import语句中出现拼写错误(大小写错误)。 The file is named "fullcalendar" while the import is called by "fullCalendar" (notice the capital "C"). 该文件名为“ fullcalendar”,而导入文件则由“ fullCalendar”调用(注意大写字母“ C”)。 When you fix this (make the capital "C" simple in the import statement) it will run the "npm run prod" command successfully. 解决此问题时(在import语句中使大写字母“ C”简单),它将成功运行“ npm run prod”命令。 It should be noted that, for me, this did not occur in the windows environment for some reason, but only occurs in the Linux environment. 应该注意的是,对我来说,由于某种原因这不是在Windows环境中发生的,而只是在Linux环境中发生的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用npm vue-cli时出错 - Error when using npm vue-cli 生产构建自定义选项。 Vue-cli 3 - Production build customization options. Vue-cli 3 如何在 vue-cli 中设置生产构建路径? - How can I set production build path in vue-cli? 当我运行 vue-cli -service build -mode test.I get an error.Process is not defined。 但是使用vue-cli -service build 不报这个错误 - When I run vue-cli -service build -mode test.I get an error.Process is not defined. But using vue-cli -service build does not report this error Vue 3 与组合 API 不同的 object 结构用于在开发构建或生产构建中使用 Vue-CLI 4 获取上下文/全局属性? - Vue 3 with Composition API different object structure for getting context/globalProperties with Vue-CLI 4 in dev build or production build? 如何使用 Webpack (vue-cli) 从生产构建中排除 CommonJS 库 - How to exclude CommonJS libs from production build with Webpack (vue-cli) vue-cli - 无法为开发模式构建 - vue-cli - cannot build for development mode 如何在修改指定文件时运行vue-cli build命令? - How to run vue-cli build command when specified files modified? 没有 vue-cli 的 Vue,在 express 服务器上运行 - Vue without vue-cli, run on an express server Vue CLI 3:使用Foundation 6构建生产 - Vue CLI 3: production build with Foundation 6
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM