【问题标题】:vue-cli-service build throws E2BIGvue-cli-service 构建抛出 E2BIG
【发布时间】:2021-03-08 19:02:55
【问题描述】:

我正在使用 Vue.js 2 开发应用程序。我使用的是 Ubuntu 20.04.1 LTS。我的package.json 文件如下所示:

{
  "name": "my-app",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "vue": "^2.6.12",
    "vue-router": "^3.4.9",
    "vuex": "^3.6.2",
    "vuex-persistedstate": "^4.0.0-beta.3",
     ...and others
  },
  "devDependencies": {
    ...some dependencies
  }
}

当我运行npm run build 时,出现以下异常:

> vue-cli-service build


⠹  Building for production...internal/child_process.js:403
    throw errnoException(err, 'spawn');
    ^

Error: spawn E2BIG
    at ChildProcess.spawn (internal/child_process.js:403:11)
    at Object.spawn (child_process.js:553:9)
    at new PoolWorker (/workspace/___/___/___/node_modules/thread-loader/dist/WorkerPool.js:46:43)
    at WorkerPool.createWorker (/workspace/___/___/___/node_modules/thread-loader/dist/WorkerPool.js:341:23)
    at WorkerPool.distributeJob (/workspace/___/___/___/node_modules/thread-loader/dist/WorkerPool.js:335:28)
    at runQueue (/workspace/___/___/___/node_modules/neo-async/async.js:8099:9)
    at processTicksAndRejections (internal/process/task_queues.js:75:11) {
  errno: -7,
  code: 'E2BIG',
  syscall: 'spawn'
}
npm ERR! code 1
npm ERR! path /workspace/___/___/___
npm ERR! command failed
npm ERR! command sh -c vue-cli-service build

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/___/.npm/_logs/2021-03-08T18_57_06_018Z-debug.log

但是,当我运行 npm run serve 时,一切正常。这里有什么问题?如果您需要我未包含的任何其他文件,请告诉我。

【问题讨论】:

  • 您的整个项目是否有任何 ESlint 错误?
  • npm run serve 不会返回任何警告或错误,它工作正常。我还尝试从 package.json 中删除所有与 ESlint 相关的依赖项并再次重新安装所有依赖项,但问题仍然存在。

标签: vue.js vue-cli


【解决方案1】:

我发现了错误所在。我试图读取vue.config.js 中的一些文件内容,如下所示:

const fs = require('fs-extra');
const path = require('path');

// read data
const data = fs.readJsonSync(path.resolve(__dirname, 'data.json'), {
  throws: false
});

// set process variables
process.env.VUE_APP_DATA = JSON.stringify(data);

module.exports = {
  devServer: {
    disableHostCheck: true,
  },
};

删除fs.readJsonSync(...)后,它开始工作了。

【讨论】:

    猜你喜欢
    • 2020-01-31
    • 2020-05-07
    • 2021-07-24
    • 2019-06-03
    • 2019-02-07
    • 2020-05-09
    • 2020-08-08
    • 2019-05-22
    • 2020-01-09
    相关资源
    最近更新 更多