2016-10-21 114 views
0

隨着幾乎所有的NPM包,我試圖用vue.js 1.0使用我收到此錯誤:Vue.js browserify找不到模塊

{ Error: Cannot find module '!!./../../../node_modules/css-loader/index.js!./../../../node_modules/vue-loader/lib/style-rewriter.js!./../../../node_modules/vue-loader/lib/selector.js?type=style&index=0!./dashboard.vue' from '/Users/jamie/Code/forum/node_modules/vue-html5-editor/dist' 
    at /Users/jamie/Code/forum/node_modules/resolve/lib/async.js:46:17 
    at process (/Users/jamie/Code/forum/node_modules/resolve/lib/async.js:173:43) 
    at ondir (/Users/jamie/Code/forum/node_modules/resolve/lib/async.js:188:17) 
    at load (/Users/jamie/Code/forum/node_modules/resolve/lib/async.js:69:43) 
    at onex (/Users/jamie/Code/forum/node_modules/resolve/lib/async.js:92:31) 
    at /Users/jamie/Code/forum/node_modules/resolve/lib/async.js:22:47 
    at FSReqWrap.oncomplete (fs.js:117:15) 

它驅使我瘋了!我正在使用vue.jsbrowserify。到處找網站:

https://github.com/webpack/css-loader/issues/240 https://github.com/webpack/css-loader/issues/180 https://github.com/webpack/css-loader/issues/295 https://github.com/webpack/css-loader/issues/163

似乎沒有任何工作!我究竟做錯了什麼!?

2包在那裏我已經這個問題:

https://github.com/lian-yue/vue-upload-component/
https://github.com/PeakTai/vue-html5-editor

gulpfile

const elixir = require('laravel-elixir'); 
require('laravel-elixir-vueify'); 
require('laravel-elixir-stylus'); 



    elixir(mix => { 
     mix.browserify('main.js'); 
     mix.styles([ 
       './node_modules/normalize-css/normalize.css', 
       './node_modules/nprogress/nprogress.css', 
       './node_modules/sweetalert/dist/sweetalert.css', 
       ]); 
     mix.stylus('app.styl'); 
    }); 

一種解決方案真正幫助我。

- 編輯 -

{ 
    "private": true, 
    "scripts": { 
    "prod": "gulp --production", 
    "dev": "gulp watch" 
    }, 
    "devDependencies": { 
    "gulp": "^3.9.1", 
    "laravel-elixir": "^6.0.0-9", 
    "laravel-elixir-browserify-official": "^0.1.3", 
    "laravel-elixir-stylus": "^2.0.3", 
    "vue-html5-editor": "^0.5.1" 
    }, 
    "dependencies": { 
    "browserify": "^13.1.0", 
    "laravel-elixir-vueify": "^2.0.0", 
    "normalize-css": "^2.3.1", 
    "nprogress": "^0.2.0", 
    "stylus": "^0.54.5", 
    "sweetalert": "^1.1.3", 
    "vue": "^1.0.26", 
    "vue-resource": "^0.9.3", 
    "vue-router": "^0.7.13", 
    "vue-spinner": "^1.0.2", 
    "vue-upload-component": "^2.0.0-beta" 
    } 
} 
+0

你能否提供你的packages.json文件? –

+0

是的!請參閱我的編輯。 – Jamie

+0

Weird.Maybe你可以嘗試安裝這些babel依賴https://github.com/vuejs/vueify/blob/master/package.json#L38,我不確定,但似乎vue-upload-component使用ES2015 。 –

回答

2

這些都是webpack包和你使用browserify。如果你需要使用webpack軟件包,你應該使用webpack作爲你的捆綁軟件。

我確實已經安裝了vue-upload-component軟件包,看看browserifyelixir有多容易,但至少可以說是很尷尬。我沒有得到它的工作,因爲它使用巴貝爾變換編譯vue文件,所以首先你需要手動拉它們,然後你可能需要編寫一個elixir擴展來使用這些變換來使它工作。很顯然,每個webpack軟件包都會有所不同,所以每次安裝時都需要這樣做,這很不方便。

0

我有一些運氣,改變了我想用來使用webpack -p而不是僅僅webpack Vue組件的配置輸出。

然後我可以採取無熱模塊代碼輸出,並把它通過browserify

browserify file.js --standalone SomeLibrary > file.browser.js 

哪裏file.js的WebPack -p輸出,SomeLibrary的名字,你想在全球範圍內的窗口來自browserify包裝,並且file.browser.js是您的項目中包含的結果文件。

相關問題