2017-03-23 20 views
3

我一直在使用Laravel混合編譯我的樣式表和javascript文件,代碼如下:
未捕獲的ReferenceError:要求未在規定的要求(「./引導」)Laravel混合

const { 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') 
// .sass('resources/assets/sass/app.scss', 'public/css'); 

mix.babel([ 
    'public/js/plugins/loaders/pace.min.js', 
    'resources/assets/js/app.js', 
    'public/js/plugins/loaders/blockui.min.js', 
    'public/js/plugins/ui/nicescroll.min.js', 
    'public/js/plugins/ui/drilldown.js', 
    'public/js/plugins/ui/fab.min.js', 
    'public/js/plugins/forms/selects/select2.min.js', 
    'public/js/plugins/forms/styling/uniform.min.js', 
    'public/js/plugins/ui/moment/moment.min.js', 
    'public/js/plugins/ui/fullcalendar/fullcalendar.min.js', 
    'public/js/core/app.js', 
    'public/js/pages/user_pages_profile.js', 
] , 'public/js/app.js'); 

mix.styles([ 
    'public/css/icons/icomoon/styles.css', 
    'resources/assets/sass/app.scss', 
    'public/css/core.css', 
    'public/css/components.css', 
    'public/css/colors.css', 
],'public/css/app.css'); 


下面是我app.js

/** 
* First we will load all of this project's JavaScript dependencies which 
* includes Vue and other libraries. It is a great starting point when 
* building robust, powerful web applications using Vue and Laravel. 
*/ 

require('./bootstrap'); //complains on this line after compilation 

/** 
* Next, we will create a fresh Vue application instance and attach it to 
* the page. Then, you may begin adding components to this application 
* or customize the JavaScript scaffolding to fit your unique needs. 
*/ 

Vue.component('example', require('./components/Example.vue')); 

const app = new Vue({ 
    el: '#app' 
}); 


它抱怨的需要
未捕獲的ReferenceError:需要完全沒有app.js定義:354,這是已編譯app.js
我曾嘗試:
1- mix.scripts
2- mix.babel(根據文檔,這將把任何ES2015代碼翻譯成所有瀏覽器都能理解的vanilla JavaScript。)
我在這裏丟失了什麼?

+0

你可以加上你得到的確切的錯誤嗎?問題中提到了 – TheFallen

+0

錯誤,但現在也在描述中添加了它。 – awebartisan

+0

嘗試使用** import **而不是** require **。 – TheFallen

回答

0

您的節點版本最有可能過期。 Node JS 6是處理ES2015模塊的第一個版本。通過運行

node -v 

如果您在使用Ubuntu 16檢查您的節點版本,你需要添加一個源代碼庫,將節點的新版本。運行下面的命令應該讓你到最新版本

cd ~ 
curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh 
sudo bash nodesource_setup.sh 
sudo apt-get install nodejs 
sudo npm update -g npm 
sudo ln -s /usr/bin/nodejs /usr/bin/node 

現在試着運行NPM運行開發,一切都應該在Laravel混合編譯罰款。

+0

其節點v7.5.0 – awebartisan

+0

奇怪。如果節點7應該識別require指令。您是否嘗試擦除node_modules並重新運行npm install? –

+0

這是一個全新的安裝。讓我再次做這個 – awebartisan

相關問題