when I run nuxt build,I got:
TypeError: __WEBPACK_IMPORTED_MODULE_4_lodash___default.a.last(...).indexOf is not a function
at r (/home/hxh/.npm-global/lib/node_modules/nuxt/dist/nuxt.js:424:65)
at /home/hxh/.npm-global/lib/node_modules/nuxt/dist/nuxt.js:618:22
at Array.map (native)
at Nuxt.generateRoutesAndFiles$ (/home/hxh/.npm-global/lib/node_modules/nuxt/dist/nuxt.js:617:43)
at tryCatch (/home/hxh/.npm-global/lib/node_modules/nuxt/node_modules/.0.10.3@regenerator-runtime/runtime.js:64:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/home/hxh/.npm-global/lib/node_modules/nuxt/node_modules/.0.10.3@regenerator-runtime/runtime.js:299:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/home/hxh/.npm-global/lib/node_modules/nuxt/node_modules/.0.10.3@regenerator-runtime/runtime.js:116:21)
at onFulfilled (/home/hxh/.npm-global/lib/node_modules/nuxt/node_modules/.4.6.0@co/index.js:65:19)
@bimohxh Seems problem with importing and using lodash. Can you please share how are you using lodash inside project?
@pi0 I find loadsh used in my projects has 3 files:
.nuxt/server.js
dist/_nuxt/server-bundle.js
and https://github.com/ali-sdk/ali-oss/blob/master/dist/aliyun-oss-sdk.min.js
Anyway providing a repository that we can locally test your code? :D Seems incompatibility is not from nuxt.js
@pi0 my repo is https://github.com/bimohxh/new-awesomes !thanks
@pi0 I have remove the aliyun-oss-sdk.min.js file, but still get the error
@pi0 I find where the error is, in nuxt.config.js:
plugins: ['~plugins/vue-icon', '~plugins/icon', '~plugins/element-ui', '~plugins/common', { src: '~plugins/pagination', ssr: false }, { src: '~plugins/editor', ssr: false }, { src: '~plugins/upload', ssr: false }]
if the plugins config has { src: '...', ssr: false } will lead this error
@bimohxh Sorry for delay answering. Do you mean it works with blahblah but not working with {src: 'blahblah', ssr:false} ?
@pi0 Yes, just this!
Thanks for report. Will try to investigate this.
https://github.com/nuxt/nuxt.js/blob/v0.10.7/lib/build.js#L208 Here is the logic and seems ok. (Consider that with string form ssr is set to true by default!)
plugins: this.options.plugins.map((p) => {
if (typeof p === 'string') {
return { src: r(this.srcDir, p), ssr: true }
}
return { src: r(this.srcDir, p.src), ssr: (p.ssr !== false), injectAs: (p.injectAs || false) }
}),
Would you please compare .nuxt/index.js file when using object and plain string ?
@pi0 I have test this,the diffrent in .nuxt/index.js is :
If object (plugins: ['~plugins/vue-icon', '~plugins/icon', '~plugins/element-ui', '~plugins/common', { src: '~plugins/pagination.js', ssr: false }, { src: '~plugins/editor.js', ssr: false }, { src: '~plugins/upload', ssr: false }, { src: '~plugins/i18n.js', injectAs: 'i18n' }]):
if (process.browser) {
require('~plugins/pagination.js')
}
if (process.browser) {
require('~plugins/editor.js')
}
if (process.browser) {
require('~plugins/upload')
}
let i18n = require('~plugins/i18n.js')
i18n = i18n.default || i18n
app['i18n'] = i18n
If string: (plugins: ['~plugins/vue-icon', '~plugins/icon', '~plugins/element-ui', '~plugins/common', '~plugins/pagination.js', '~plugins/editor.js', '~plugins/upload', '~plugins/i18n.js'])
require('~plugins/pagination.js')
require('~plugins/editor.js')
require('~plugins/upload')
require('~plugins/i18n.js')
If string then ssr => true so that requires are unguarded! For browser only plugins we should use object form :)) /CC @Atinux
@Atinux I have finished my app for some time, but this error cause that I cant build and deploy it, So this is a fatal error. I try to get the latest dev branch, but this still not be solved. I don't know your issue priority, but this error must be the most important! I wish you take just a bit time to solve this, thanks!
@bimohxh if you understand how to fix , you can fork it , and build it , and use your build version for your project util nuxt.js have new release .
It's not best practice , but very useful for you can deploy ASAP .
@bimohxh sorry for the delay, I tried to build your project and everything works, did you solve the error?
@Atinux What? I try to build just right now, It works done! But I change nothing, how it works? Thanks very much!!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
@Atinux What? I try to build just right now, It works done! But I change nothing, how it works? Thanks very much!!