部署Cra-Universal应用程序后,Firebase Functions会引发eslint错误

时间:2020-01-01 21:20:33

标签: javascript reactjs google-cloud-functions eslint server-side-rendering

我目前正在尝试将cra-unviersal应用程序部署到firebase功能。因此,我关注了this guide.

构建等并尝试部署后,函数返回1724问题,其中509为错误:

...
/Users/user/Documents/Entwicklung/React/auriga_final/functions/crau-dist/server/bundle.js
  1:1      error    Expected an assignment or function call and instead saw an expression  no-unused-expressions
  1:139    warning  Unexpected use of comma operator                                       no-sequences
  1:157    error    Expected an assignment or function call and instead saw an expression  no-unused-expressions

...

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions@ lint: `eslint .`
npm ERR! Exit status 1
npm ERR! 

功能package.json,类似于root的package.json:

"dependencies": {
    "firebase-admin": "^8.6.0",
    "firebase-functions": "^3.3.0",
    "bootstrap": "^4.4.1",
    "history": "^4.10.1",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.3.0",
    "smoothscroll-polyfill": "^0.4.4"
  },
  "devDependencies": {
    "eslint": "^5.12.0",
    "eslint-plugin-promise": "^4.0.1",
    "firebase-functions-test": "^0.1.6",
    "cra-universal": "^4.3.1"
  },

在/ functions内部运行npm i后可能会引起注意的警告:

npm WARN babel-preset-cra-universal@4.3.1 requires a peer of @babel/core@7.5.5 but none is installed. You must install peer dependencies yourself.
npm WARN babel-preset-cra-universal@4.3.1 requires a peer of @babel/core@7.5.5 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-react-app@5.1.0 requires a peer of eslint@6.x but none is installed. You must install peer dependencies yourself.
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.

顺便说一句,该指南说要更新crau.config.js-通过使用npx cra-universal init我可以创建这样的文件,但是它说env没有定义:

module.exports = {
    modifyWebpack: config => {
        const newConfig = {
            ...config,
            output: {
                ...config.output,
                libraryTarget: 'commonjs2'
            },
            entry: env ? './server/index.js' : './server/app.js'
        };
        return newConfig;
    }
};

0 个答案:

没有答案