skyrpex / laravel-nuxt-js

Build a SPA with Laravel and Nuxt.
https://www.npmjs.com/package/laravel-nuxt
MIT License
146 stars 20 forks source link

TypeError: Cannot read property 'compilation' of undefined #21

Closed MicroDreamIT closed 4 years ago

MicroDreamIT commented 5 years ago

I am having this error while I run build

> @ build F:\temp\nuxtLaravel
> laravel-nuxt build

  nuxt:build Building... +0ms
» baseURL: /                                                                                                                                                      nuxt:axios 16:31:12
» browserBaseURL: /                                                                                                                                               nuxt:axios 16:31:12
  nuxt:build App root: F:\temp\nuxtLaravel\resources\nuxt +0ms
  nuxt:build Generating F:\temp\nuxtLaravel\.nuxt files... +0ms
  nuxt:build Generating files... +30ms
  nuxt:build Generating routes... +16ms
  nuxt:build Building files... +125ms

 ERROR 

  TypeError: Cannot read property 'compilation' of undefined

  - ProgressPlugin.js:211 ProgressPlugin.apply
    [nuxtLaravel]/[webpack]/lib/ProgressPlugin.js:211:19

  - Tapable.js:375 Compiler.apply
    [nuxtLaravel]/[nuxt]/[tapable]/lib/Tapable.js:375:16

  - webpack.js:33 webpack
    [nuxtLaravel]/[nuxt]/[webpack]/lib/webpack.js:33:19

  - builder.js:524 compilers.compilersOptions.map.compilersOption
    [nuxtLaravel]/[nuxt]/lib/builder/builder.js:524:24

  - Array.map

  - builder.js:523 Builder.webpackBuild
    [nuxtLaravel]/[nuxt]/lib/builder/builder.js:523:39

  - builder.js:168 Builder.build
    [nuxtLaravel]/[nuxt]/lib/builder/builder.js:168:16

TypeError: Cannot read property 'compilation' of undefined
    at ProgressPlugin.apply (F:\temp\nuxtLaravel\node_modules\webpack\lib\ProgressPlugin.js:211:19)
    at Compiler.apply (F:\temp\nuxtLaravel\node_modules\nuxt\node_modules\tapable\lib\Tapable.js:375:16)
    at webpack (F:\temp\nuxtLaravel\node_modules\nuxt\node_modules\webpack\lib\webpack.js:33:19)
    at compilers.compilersOptions.map.compilersOption (F:\temp\nuxtLaravel\node_modules\nuxt\lib\builder\builder.js:524:24)
    at Array.map (<anonymous>)
    at Builder.webpackBuild (F:\temp\nuxtLaravel\node_modules\nuxt\lib\builder\builder.js:523:39)
    at Builder.build (F:\temp\nuxtLaravel\node_modules\nuxt\lib\builder\builder.js:168:16)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ build: `laravel-nuxt build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ 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!     C:\Users\Sharif\AppData\Roaming\npm-cache\_logs\2019-06-24T10_31_20_211Z-debug.log
skyrpex commented 5 years ago

Can you share your nuxt.config file? My guess is that the error may be there, but not sure...

MicroDreamIT commented 5 years ago

@skyrpex here is nuxt config

const laravelNuxt = require("laravel-nuxt");

module.exports = laravelNuxt({
    // Options such as mode, srcDir and generate.dir are already handled for you.
    modules: [],
    plugins: [],
});
skyrpex commented 5 years ago

hmm it looks fine to me! I would ask you to upload a repository reproducing the issue. Maybe it's because a specific version of the underlying libraries.

MicroDreamIT commented 5 years ago

@skyrpex I am using node v10.15.3 in windows here is git url https://github.com/MicroDreamIT/nuxtLaravel

skyrpex commented 5 years ago

I just installed in my Mac using yarn v1.16.0 and composer v1.8.0. After running yarn start, Nuxt errored telling me that resources/nuxt/pages directory is missing, which is true. You should add an empty page, like resources/nuxt/pages/index.vue.

~/Code/nuxtLaravel   master ●  yarn start
yarn run v1.16.0
$ laravel-nuxt dev
[laravel] Laravel development server started: <http://127.0.0.1:8001>
[nuxt] › [HPM] Proxy created: [ '**/*', '!/__laravel_nuxt__' ]  ->  http://127.0.0.1:8001
[nuxt] › baseURL: /
[nuxt] › browserBaseURL: /
[nuxt] ERROR 

  Error: Couldn't find a `pages` directory in /Users/cristian/Code/nuxtLaravel/r  esources/nuxt. Please create one under the project root

  - builder.js:147 Builder.build
    [nuxtLaravel]/[nuxt]/lib/builder/builder.js:147:17

  - task_queues.js:89 processTicksAndRejections
    internal/process/task_queues.js:89:5
MicroDreamIT commented 5 years ago

I have done it before but did not work. I have created one again still dont work. Please UPDATE the project you will see. But Error in your computer is different, this is strange.

F:\temp\nuxtLaravel>npm run build

> @ build F:\temp\nuxtLaravel
> laravel-nuxt build

  nuxt:build Building... +0ms
» baseURL: /                                                                                                                                                      nuxt:axios 19:15:36
» browserBaseURL: /                                                                                                                                               nuxt:axios 19:15:36
  nuxt:build App root: F:\temp\nuxtLaravel\resources\nuxt +0ms
  nuxt:build Generating F:\temp\nuxtLaravel\.nuxt files... +2ms
  nuxt:build Generating files... +44ms
  nuxt:build Generating routes... +6ms
  nuxt:build Building files... +170ms

 ERROR 

  TypeError: Cannot read property 'compilation' of undefined

  - ProgressPlugin.js:211 ProgressPlugin.apply
    [nuxtLaravel]/[webpack]/lib/ProgressPlugin.js:211:19

  - Tapable.js:375 Compiler.apply
    [nuxtLaravel]/[nuxt]/[tapable]/lib/Tapable.js:375:16

  - webpack.js:33 webpack
    [nuxtLaravel]/[nuxt]/[webpack]/lib/webpack.js:33:19

  - builder.js:524 compilers.compilersOptions.map.compilersOption
    [nuxtLaravel]/[nuxt]/lib/builder/builder.js:524:24

  - Array.map

  - builder.js:523 Builder.webpackBuild
    [nuxtLaravel]/[nuxt]/lib/builder/builder.js:523:39

  - builder.js:168 Builder.build
    [nuxtLaravel]/[nuxt]/lib/builder/builder.js:168:16

TypeError: Cannot read property 'compilation' of undefined
    at ProgressPlugin.apply (F:\temp\nuxtLaravel\node_modules\webpack\lib\ProgressPlugin.js:211:19)
    at Compiler.apply (F:\temp\nuxtLaravel\node_modules\nuxt\node_modules\tapable\lib\Tapable.js:375:16)
    at webpack (F:\temp\nuxtLaravel\node_modules\nuxt\node_modules\webpack\lib\webpack.js:33:19)
    at compilers.compilersOptions.map.compilersOption (F:\temp\nuxtLaravel\node_modules\nuxt\lib\builder\builder.js:524:24)
    at Array.map (<anonymous>)
    at Builder.webpackBuild (F:\temp\nuxtLaravel\node_modules\nuxt\lib\builder\builder.js:523:39)
    at Builder.build (F:\temp\nuxtLaravel\node_modules\nuxt\lib\builder\builder.js:168:16)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ build: `laravel-nuxt build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ 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!     C:\Users\Sharif\AppData\Roaming\npm-cache\_logs\2019-06-25T13_15_48_422Z-debug.log

https://ibb.co/pvyYDRY

skyrpex commented 5 years ago

I encountered this error:

 ~/Code/nuxtLaravel   master ●  yarn start
yarn run v1.16.0
$ laravel-nuxt dev
[laravel] Laravel development server started: <http://127.0.0.1:8001>
[nuxt] › [HPM] Proxy created: [ '**/*', '!/__laravel_nuxt__' ]  ->  http://127.0.0.1:8001
[nuxt] › baseURL: /
[nuxt] › browserBaseURL: /
[nuxt] 2019-06-25T13:23:49.495Z nuxt:build App root: /Users/cristian/Code/nuxtLaravel/resources/nuxt
[nuxt] 2019-06-25T13:23:49.495Z nuxt:build Generating /Users/cristian/Code/nuxtLaravel/.nuxt files...
[nuxt] 2019-06-25T13:23:49.506Z nuxt:build Generating files...
[nuxt] 2019-06-25T13:23:49.508Z nuxt:build Generating routes...
[nuxt] 2019-06-25T13:23:49.541Z nuxt:build Building files...
[nuxt] 2019-06-25T13:23:50.350Z nuxt:build Adding webpack middleware...
[nuxt] ERROR  Failed to compile with 1 errors15:23:52
[nuxt] 
[nuxt] error  in ./.nuxt/client.js
[nuxt] Module build failed: TypeError: this.setDynamic is not a function
    at PluginPass.pre (/Users/cristian/Code/nuxtLaravel/node_modules/babel-plugin-transform-runtime/lib/index.js:31:12)
    at transformFile (/Users/cristian/Code/nuxtLaravel/node_modules/@babel/core/lib/transformation/index.js:78:27)
    at runSync (/Users/cristian/Code/nuxtLaravel/node_modules/@babel/core/lib/transformation/index.js:45:3)
    at runAsync (/Users/cristian/Code/nuxtLaravel/node_modules/@babel/core/lib/transformation/index.js:35:14)
    at /Users/cristian/Code/nuxtLaravel/node_modules/@babel/core/lib/transform.js:34:34
    at processTicksAndRejections (internal/process/task_queues.js:82:9)

 @ multi webpack-hot-middleware/client?name=client&reload=true&timeout=30000&path=/__webpack_hmr ./.nuxt/client.js
[nuxt] 
[nuxt] OPEN  http://127.0.0.1:8000

I solved it removing the laravel-mix dependency and installing from scratch (maybe you should remove the yarn.lock before that). I guess that the webpack versions from laravel-mix and nuxt are incompatible in some way. I'd suggest you to remove other dependencies like bootstrap, jquery and popper.

MicroDreamIT commented 5 years ago

let me check brother