Git Product home page Git Product logo

Comments (12)

xihadandan avatar xihadandan commented on May 23, 2024

npm install已经安装了包

from nuxt-bnhcp.

Zeus-Iqd avatar Zeus-Iqd commented on May 23, 2024

@xihadandan 改成yarn install 就好了

from nuxt-bnhcp.

chengwenxin avatar chengwenxin commented on May 23, 2024

项目跑不起来 yarn install 也有各种错误

from nuxt-bnhcp.

github1586 avatar github1586 commented on May 23, 2024

@chengwenxin 什么错误

from nuxt-bnhcp.

smartsf avatar smartsf commented on May 23, 2024

升级一下webpack 就可以了

from nuxt-bnhcp.

yiibase avatar yiibase commented on May 23, 2024

我的环境:
node v8.11.3
yarn run v1.9.4
webpack 3.12.0
vue 2.9.6

yarn install 出错
████████████████████ 10% building modules[BABEL] Note: The code generator has deoptimised the styling of "/Volumes/vim/share/bnhcp/.nuxt/App.js" as it exceeds the max of "500KB".
████████████████████ 91% additional chunk assets processing
<--- Last few GCs --->

[9922:0x102802400] 997603 ms: Mark-sweep 1428.1 (1551.2) -> 1428.1 (1519.2) MB, 2322.1 / 0.0 ms last resort GC in old space requested
[9922:0x102802400] 999988 ms: Mark-sweep 1428.1 (1519.2) -> 1428.1 (1519.2) MB, 2384.8 / 0.0 ms last resort GC in old space requested

<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x2aa3aa25879
1: /* anonymous */ [/Volumes/vim/share/pinta/node_modules/webpack-sources/node_modules/source-map/lib/source-node.js:~342] [pc=0x1e2a262781af](this=0x2aa3028c209 ,chunk=0x2aa58d1ea01 <String[15]: }\r\n>,original=0x2aab866d489 )
2: SourceNode_walk [/Volumes/vim/share/pinta/node_modules/webpack-sources/node_modules/source-map/lib/sou...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [/Users/ts/.nvm/versions/node/v8.11.3/bin/node]
2: node::FatalException(v8::Isolate*, v8::Localv8::Value, v8::Localv8::Message) [/Users/ts/.nvm/versions/node/v8.11.3/bin/node]
3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/Users/ts/.nvm/versions/node/v8.11.3/bin/node]
4: v8::internal::Factory::NewUninitializedFixedArray(int) [/Users/ts/.nvm/versions/node/v8.11.3/bin/node]
5: v8::internal::(anonymous namespace)::ElementsAccessorBase<v8::internal::(anonymous namespace)::FastPackedObjectElementsAccessor, v8::internal::(anonymous namespace)::ElementsKindTraits<(v8::internal::ElementsKind)2> >::GrowCapacity(v8::internal::Handlev8::internal::JSObject, unsigned int) [/Users/ts/.nvm/versions/node/v8.11.3/bin/node]
6: v8::internal::Runtime_GrowArrayElements(int, v8::internal::Object**, v8::internal::Isolate*) [/Users/ts/.nvm/versions/node/v8.11.3/bin/node]
7: 0x1e2a251042fd
8: 0x1e2a262781af
9: 0x1e2a25ffdc5e
10: 0x1e2a25ffdda7
/bin/sh: line 1: 9922 Abort trap: 6 nuxt build
error Command failed with exit code 134.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

看了.nuxt文件夹的App.js文件有3.2M,诸如开头是
import Vue from 'vue'
import NuxtLoading from './components/nuxt-loading.vue'
let layouts = {

"_default": () => import('../layouts/default.vue' /* webpackChunkName: "layouts/default" */).then(m => m.default || m),

"_node_modules/@babel/code-frame/lib/index": () => import('../layouts/node_modules/@babel/code-frame/lib/index.js' /* webpackChunkName: "layouts/node_modules/@babel/code-frame/lib/index" */).then(m => m.default || m),"
_node_modules/@babel/generator/。。。。。。。。。省略

编辑App.js如下
import Vue from 'vue'
import NuxtLoading from './components/nuxt-loading.vue'

let layouts = {

"_default": () => import('../layouts/default.vue' /* webpackChunkName: "layouts/default" */).then(m => m.default || m)

}
let resolvedLayouts = {}

export default {
head: {"title":"bobo","meta":[{"charset":"utf-8"},{"name":"viewport","content":"width=device-width, initial-scale=1"},{"hid":"description","name":"description","content":"{{escape description }}"}],"link":[{"rel":"icon","type":"image\u002Fx-icon","href":"\u002Ffavicon.ico"},{"rel":"stylesheet","href":"\u002Fcommon\u002Fcommon.css"}],"style":[],"script":[]},
render(h, props) {
const loadingEl = h('nuxt-loading', { ref: 'loading' })
const layoutEl = h(this.layout || 'nuxt')
const templateEl = h('div', {
domProps: {
id: '__layout'
},
key: this.layoutName
}, [ layoutEl ])

const transitionEl = h('transition', {
  props: {
    name: 'layout',
    mode: 'out-in'
  }
}, [ templateEl ])

return h('div',{
  domProps: {
    id: '__nuxt'
  }
}, [
  loadingEl,
  transitionEl
])

},
data: () => ({
layout: null,
layoutName: ''
}),
beforeCreate () {
Vue.util.defineReactive(this, 'nuxt', this.$options.nuxt)
},
created () {
// Add this.$nuxt in child instances
Vue.prototype.$nuxt = this
// add to window so we can listen when ready
if (typeof window !== 'undefined') {
window.$nuxt = this
}
// Add $nuxt.error()
this.error = this.nuxt.error
},

mounted () {
this.$loading = this.$refs.loading
},
watch: {
'nuxt.err': 'errorChanged'
},

methods: {

errorChanged () {
  if (this.nuxt.err && this.$loading) {
    if (this.$loading.fail) this.$loading.fail()
    if (this.$loading.finish) this.$loading.finish()
  }
},

setLayout (layout) {
  if (!layout || !resolvedLayouts['_' + layout]) layout = 'default'
  this.layoutName = layout
  let _layout = '_' + layout
  this.layout = resolvedLayouts[_layout]
  return this.layout
},
loadLayout (layout) {
  if (!layout || !(layouts['_' + layout] || resolvedLayouts['_' + layout])) layout = 'default'
  let _layout = '_' + layout
  if (resolvedLayouts[_layout]) {
    return Promise.resolve(resolvedLayouts[_layout])
  }
  return layouts[_layout]()
  .then((Component) => {
    resolvedLayouts[_layout] = Component
    delete layouts[_layout]
    return resolvedLayouts[_layout]
  })
  .catch((e) => {
    if (this.$nuxt) {
      return this.$nuxt.error({ statusCode: 500, message: e.message })
    }
  })
}

},
components: {
NuxtLoading
}
}
再yarn start 报No SSR build!
yarn run v1.9.4
$ nuxt start

ERROR

Error: No SSR build! Please start with nuxt start --spa or build using nuxt build --universal

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

from nuxt-bnhcp.

github1586 avatar github1586 commented on May 23, 2024

@yiibase yarn dev 试试

from nuxt-bnhcp.

yiibase avatar yiibase commented on May 23, 2024

@yiibase yarn dev 试试
出现一样错误,请问能正常打包的具体环境(含版本)是 ?

from nuxt-bnhcp.

github1586 avatar github1586 commented on May 23, 2024

@yiibase
node 版本 v8.9.1
yarn 版本 1.3.2
mac系统
刚才试了一下可以的 yarn dev

from nuxt-bnhcp.

yiibase avatar yiibase commented on May 23, 2024

@yiibase
node 版本 v8.9.1
yarn 版本 1.3.2
mac系统
刚才试了一下可以的 yarn dev

您文件都没传完,敷衍的回答。虽然打包出错至少我贴出.babelrc文件,帮看看
{
"presets": ["es-2015","stage-2"],
"plugins": [
["transform-runtime", {
"helpers": false,
"polyfill": false,
"regenerator": true,
"moduleName": "babel-runtime"

    }]
],
  "compact": false

}

from nuxt-bnhcp.

github1586 avatar github1586 commented on May 23, 2024

@yiibase 项目的所有前后台文件 都已提交。

from nuxt-bnhcp.

yiibase avatar yiibase commented on May 23, 2024

@yiibase 项目的所有前后台文件 都已提交。
nuxt/dist/文件夹没有

from nuxt-bnhcp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.