zoukankan      html  css  js  c++  java
  • react 记录:运行npm run eject命令暴露配置文件都报这个错误

    问题: react 使用create-react-app命令创建一个项目,运行npm run eject命令暴露配置文件都报这个错误

    原因:主要是脚手架添加 .gitgnore文件,但是却没有本地仓库

    错误:

    Remove untracked files, stash or commit any changes, and try again.
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! react-app@0.1.0 eject: `react-scripts eject`
    npm ERR! Exit status 1
    npm ERR! 
    npm ERR! Failed at the react-app@0.1.0 eject script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

    解决:

    create-react-app my-react-app
    cd my-react-app
    git init
    git add .
    git commit -m 'Saving before ejecting'
    npm run eject

    按照以上顺序就可以正常使用

    暴露配置后,初始目录如下:

    env.js: 环境相关的配置,自动识别 以 .env 开头的文件,例如:根目录下创建 .env.local,内容:

    # .env.local
    PORT=2000

    paths: 给 webpack 提供相关的路径

    polyfills.js:  三个方法,即三个垫片

    webpack.config.dev.js: 开发环境配置

    ...

  • 相关阅读:
    css3中的位置移动
    css中伪元素选择器
    css中伪类选择器
    html5之属性选择器
    html5的文本属性
    html5的视频和音频使用
    常用的linux命令
    常见的http状态码
    springboot之安装和启动es
    linux版本的jdk安装
  • 原文地址:https://www.cnblogs.com/ostrich-sunshine/p/10466830.html
Copyright © 2011-2022 走看看