“文件”参数必须为字符串类型。在npm run上收到的未定义类型运行部署到gh-pages

Kru*_*Lia 16 javascript npm github-pages reactjs

我正在尝试将ghd页面部署到React应用程序。我以前做过,但这是我第一次遇到这种错误。它说

“文件”参数必须为字符串类型。接收类型未定义

我尝试删除node_modules文件夹,并使用npm install重新安装了所有软件包,但仍然发现相同的错误

以下是我的package.json文件

{
      "name": "qrummy",
      "version": "0.1.0",
      "homepage": "https://quiph.github.io/QRummy/",
      "private": true,
      "dependencies": {
        "firebase": "^6.2.4",
        "gh-pages": "^2.1.0",
        "react": "^16.8.6",
        "react-dom": "^16.8.6",
        "react-scripts": "3.0.1"
      },
      "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test",
        "predeploy": "npm run build",
        "deploy": "gh-pages -d build",
        "eject": "react-scripts eject"
      },
      "eslintConfig": {
        "extends": "react-app"
      },
      "browserslist": {
        "production": [
          ">0.2%",
          "not dead",
          "not op_mini all"
        ],
        "development": [
          "last 1 chrome version",
          "last 1 firefox version",
          "last 1 safari version"
        ]
      }
    }
Run Code Online (Sandbox Code Playgroud)

这是我的主要index.js文件

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';

ReactDOM.render(<App />, document.getElementById('root'));

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
serviceWorker.unregister();
Run Code Online (Sandbox Code Playgroud)

错误输出如下

 qrummy@0.1.0 deploy /home/qtalkdev/Krunal/github/QRummy
> gh-pages -d build

The "file" argument must be of type string. Received type undefined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! qrummy@0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the qrummy@0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/qtalkdev/.np`enter code here`m/_logs/2019-08-01T17_28_14_611Z-debug.log
Run Code Online (Sandbox Code Playgroud)

小智 19

看来当前版本无法正常工作。我今天也遇到了同样的问题。卸载gh-pages模块。安装了版本2.0.1,并且可以正常工作。

  • 哇,这是在5个小时前回答的。好一个! (4认同)

归档时间:

查看次数:

1425 次

最近记录:

6 年,4 月 前