0

我正在尝试将 Vuelidate 与 Webpacker 一起用于我的 Rails 应用程序。通常我只需要为我的 packages.json 运行以下命令来构建并部署到我的应用程序中:

RAILS_ENV=production bundle exec rake assets:clobber
RAILS_ENV=production bundle exec rake assets:clean
RAILS_ENV=production bundle exec rake assets:precompile

但这在产品中不起作用,因为我添加了 Vuelidate(在开发中工作正常)。

Using /home/my_user/my_app/config/webpacker.yml file for setting up webpack paths
Compiling…
Compilation failed:
Hash: a535894e7898c0a336a3
Version: webpack 3.5.6
Time: 13838ms
                                       Asset       Size  Chunks             Chunk Names
             app-36e1d2de960efd5bf847.js.map    17.4 kB       2  [emitted]  app
           dashboard-9cadea07287686e15eed.js      99 kB       0  [emitted]  dashboard
                 app-36e1d2de960efd5bf847.js    1.65 kB       2  [emitted]  app
    app-4758d50be4328c1ed27fc08a09d9dae2.css  119 bytes       2  [emitted]  app
       dashboard-9cadea07287686e15eed.js.map     808 kB       0  [emitted]  dashboard
     application-06c4c55e7d8c8e2ea0de.js.map     703 kB       1  [emitted]  application
         application-06c4c55e7d8c8e2ea0de.js    83.9 kB       1  [emitted]  application
app-4758d50be4328c1ed27fc08a09d9dae2.css.map  117 bytes       2  [emitted]  app
              app-36e1d2de960efd5bf847.js.gz  843 bytes          [emitted]
      application-06c4c55e7d8c8e2ea0de.js.gz    30.5 kB          [emitted]
        dashboard-9cadea07287686e15eed.js.gz    35.4 kB          [emitted]
                               manifest.json  518 bytes          [emitted]
   [1] (webpack)/buildin/global.js 509 bytes {0} {1} [built]
   [2] ./app/javascript/packs/app.vue + 2 modules 1.65 kB {2} [built]
   [3] ./node_modules/extract-text-webpack-plugin/dist/loader.js?{"omit":1,"remove":true}!./node_modules/vue-style-loader!./node_modules/css-loader?minimize!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-18f420a0","scoped":true,"hasInlineConfig":false}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./app/javascript/packs/app.vue 41 bytes {2} [built]
   [5] ./app/javascript/packs/application.js 1.92 kB {1} [built]
   [6] ./app/javascript/packs/dashboard.js + 1 modules 45.1 kB {0} [built]
   [8] ./node_modules/css-loader?minimize!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-18f420a0","scoped":true,"hasInlineConfig":false}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./app/javascript/packs/app.vue 220 bytes [built]
    + 6 hidden modules

ERROR in ./app/javascript/packs/application.js
Module not found: Error: Can't resolve 'vuelidate' in '/home/my_user/my_app/app/javascript/packs'
 @ ./app/javascript/packs/application.js 13:0-34

ERROR in ./app/javascript/packs/dashboard.js
Module not found: Error: Can't resolve 'vuelidate' in '/home/my_user/my_app/app/javascript/packs'
 @ ./app/javascript/packs/dashboard.js 35:0-34

ERROR in ./app/javascript/packs/application.js
Module not found: Error: Can't resolve 'vuelidate/lib/validators' in '/home/my_user/my_app/app/javascript/packs'
 @ ./app/javascript/packs/application.js 14:0-59

ERROR in ./app/javascript/packs/dashboard.js
Module not found: Error: Can't resolve 'vuelidate/lib/validators' in '/home/my_user/my_app/app/javascript/packs'
 @ ./app/javascript/packs/dashboard.js 36:0-72
Child extract-text-webpack-plugin node_modules/extract-text-webpack-plugin/dist node_modules/css-loader/index.js?minimize!node_modules/vue-loader/lib/style-compiler/index.js?{"vue":true,"id":"data-v-18f420a0","scoped":true,"hasInlineConfig":false}!node_modules/vue-loader/lib/selector.js?type=styles&index=0!app/javascript/packs/app.vue:
       [0] ./node_modules/css-loader?minimize!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-18f420a0","scoped":true,"hasInlineConfig":false}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./app/javascript/packs/app.vue 220 bytes {0} [built]
        + 1 hidden module

这是我的 package.json 文件:

{
  "license": "UNLICENSED",
  "dependencies": {
    "@rails/webpacker": "^3.0.1",
    "vue": "^2.4.3",
    "vue-loader": "^13.0.4",
    "vue-resource": "^1.3.4",
    "vue-template-compiler": "^2.4.3",
    "vuelidate": "^0.5.0"
  },
  "devDependencies": {
    "webpack-dev-server": "^2.8.1"
  }
}

我猜这个包没有正确安装到/home/my_user/my_app/app/javascript/packs. 知道我将如何解决这个问题吗?

提前致谢!

4

0 回答 0