标签: create-react-app

编辑包是node_modules在create-react-app项目中没有效果

我正在尝试在本地处理一个包,该包是反应项目中的依赖项。我想在主反应项目中运行时调试问题。

简单地使用yarn link会创建重复版本的反应,从而破坏钩子。(我也尝试过yarn link反应和反应-dom,它得到了哈利,我看到了其他问题)

于是我心里想,我有一个主意。我可以这样做:

rm ./node_modules/<my-package>/dist
ln -s /<path-to-my-dev-package>/dist ./node_modules/<my-package>/dist
Run Code Online (Sandbox Code Playgroud)

这也是等价的。我只需要先运行yarn build我的包,然后再在我的应用程序中测试它。

问题是,我无法让纱线“看到”这些变化。

我已经验证了符号链接是否存在。我已经验证了构建文件中的更改。

但无论我做什么,我看到的都是旧的非符号链接版本。

我试过:

yarn cache clean
yarn start
Run Code Online (Sandbox Code Playgroud)

但当我运行我的项目时,它仍然看到我的包的旧/删除版本(甚至不再存在)

我怎样才能让它“刷新”到新的符号链接构建文件?

总长DR

即使我不使用符号链接.. 当我运行应用程序时,我对 node_modules 中的包所做的任何更改都不会反映出来。

所以真正的问题是,这些是如何node_modules缓存在 create-react-app 中的,以及如何清除它以便node_modules看到我的更改,以便我可以调试它们。

reactjs create-react-app yarnpkg

3
推荐指数
1
解决办法
853
查看次数

React Native Google 移动广告不起作用。安装 npm add react-native-google-mobile-ads 后,我遇到了一些错误,请检查以下错误

安装npm add react-native-google-mobile-ads后出现错误。我在这里发布了错误,请检查,这里我添加了我的 android build.gradle 文件和应用程序级别 build.gradle 文件 *如何指定compileSdkVersion?*

1: Task failed with an exception.
        -----------
        * Where:
        Build file 'C:\Users\Admin\Desktop\ReactNative\Firebase\hellworldfirebaseeekkl\node_modules\react-native-google-mobile-ads\android\build.gradle' line: 75
        * What went wrong:
        A problem occurred evaluating project ':react-native-google-mobile-ads'.
        > Cannot get property 'googleMobileAdsJson' on extra properties extension as it does not exist
        * Try:
        > Run with --stacktrace option to get the stack trace.
        > Run with --info or --debug option to get more log output.
        > Run with --scan to get full …
Run Code Online (Sandbox Code Playgroud)

admob firebase react-native create-react-app

3
推荐指数
1
解决办法
3620
查看次数

npx create-react-app 似乎不起作用

我正在尝试通过运行以下命令来创建 React 应用程序样板

npx create-react-app my-app

我收到以下错误

npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path C:\Users\dejean\AppData\Roaming\npm
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, lstat 'C:\Users\dejean\AppData\Roaming\npm'   
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\dejean\AppData\Local\npm-cache\_logs\2023-06-27T18_53_22_682Z-debug-0.log

Run Code Online (Sandbox Code Playgroud)

我使用节点 18.16.1 和 npm 9.5.1

node.js npm reactjs create-react-app npx

3
推荐指数
1
解决办法
5734
查看次数

create-react-app如何在html中直接使用导入的脚本

我在使用create-react-app生成的反应应用程序中使用bootstrap

以下是我在index.html中使用的两个导入

<script src="./vendor/jquery-3.1.0.min.js"></script>
<script src="./vendor/bootstrap.min.js"></script>
Run Code Online (Sandbox Code Playgroud)

但是在代码中,当我使用类似的东西

$('.dropdown').dropdown()
Run Code Online (Sandbox Code Playgroud)

我得到一个错误 - 错误'$'没有定义no-undef 有人可以帮我解决这个问题.谢谢!

reactjs twitter-bootstrap-3 create-react-app

2
推荐指数
1
解决办法
1562
查看次数

使用create-react-app'未捕获的ReferenceError:jQuery未定义'

我正在使用create-react-app构建一个React 应用,以便该应用可以用于服务器。

导入诸如“ affix.js”之类的引导javascript插件时,出现错误“未捕获的ReferenceError:未定义jQuery”,并且不再加载该页面。

我正在通过index.js文件导入所有模块,因为使用create-react-app似乎要从index.html文件加载“ src”和“ link”导入。

像这样导入bootstrap插件:import'bootstrap / js / affix.js'

已尝试以以下方式在jindex.js文件顶部导入jquery,但没有任何效果:

  1. 从'jquery'导入jquery
  2. 从窗口'jquery'导入jquery。$ = window.jQuery = jquery;
  3. 从'jquery'导入jQuery
  4. 从'jquery'导入$
  5. 导入'jquery / dist / jquery.js';
  6. require('./ node_modules / jquery / dist / jquery.js')

有任何想法吗?

jquery twitter-bootstrap reactjs create-react-app

2
推荐指数
2
解决办法
8144
查看次数

babel-plugin-react-css-modules添加类但不转换css

我正在尝试使用babel-plugin-react-css-modules弹出的副本create-react-app来限制我的LESS CSS.

我已经设法安装和配置插件,它正在使用styleName属性正确设置范围类名,我已将其配置为使用LESS以及文档.

但是,在导入生成的CSS时,它不会转换类名以匹配元素上设置的类名.这是我webpack.config.dev.js和App.js文件的相关部分.

module: {
    // First, run the linter.
    // It's important to do this before Babel processes the JS.
    preLoaders: [
        {
            test: /\.(js|jsx)$/,
            loader: 'eslint',
            include: paths.appSrc,
        }
    ],
    loaders: [
        // ** ADDING/UPDATING LOADERS **
        // The "url" loader handles all assets unless explicitly excluded.
        // The `exclude` list *must* be updated with every change to loader extensions.
        // When adding a new loader, you …
Run Code Online (Sandbox Code Playgroud)

reactjs webpack react-css-modules create-react-app

2
推荐指数
1
解决办法
1437
查看次数

如何仅将JavaScript库包含在create-react-app的生产构建文件中?

我正在尝试添加一个JavaScript库,该库仅包含在create-react-app生成的生产构建文件中。

最好的方法是什么?

具体来说,我试图包括Rollbar.js客户端错误监视库。我不希望它在开发/测试环境中每次出现错误时都触发,因此我只希望它包含在运行时生成的文件中npm run build。

javascript reactjs webpack create-react-app

2
推荐指数
1
解决办法
1434
查看次数

创建未安装的React App,显示错误并中止安装

我重新安装了Node.js和Yarn。现在我收到此错误。

我的环境信息是:

节点:v8.12.0

NPM:6.4.1

纱:1.10.1

作业系统:Windows 10

PS C:\Users\mdbel\Desktop\Project\redux> npx create-react-app learnredux

Creating a new React app in C:\Users\mdbel\Desktop\Project\redux\learnredux.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

yarn add v1.10.1
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.1.tgz: Request failed \"404 Not Found\"".
info If you think this is a bug, please open a bug report with the information provided in "C:\\Users\\mdbel\\Desktop\\Project\\redux\\learnredux\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command. …
Run Code Online (Sandbox Code Playgroud)

node.js npm reactjs create-react-app yarnpkg

2
推荐指数
5
解决办法
4813
查看次数

错误:无法加载插件导入:部署create-react-app时找不到模块'eslint-plugin-import'

我是create-react-app的新手。我只是使用进行了快速设置,redux并且使用react-router-dom可以很好地在计算机上构建它yarn build,但是当推到Scalingo或Heroku时,构建失败,并出现以下错误:

 ./src/index.jsx
       Error: Failed to load plugin import: Cannot find module 'eslint-plugin-import'
       Referenced from:
       at Array.forEach (<anonymous>)
       at Array.reduceRight (<anonymous>)
Run Code Online (Sandbox Code Playgroud)

我没有做任何定制部署的工作,只是推送到生产环境。

这是完整的部署日志:

Enumerating objects: 74, done.
Counting objects: 100% (74/74), done.
Delta compression using up to 4 threads
Compressing objects: 100% (68/68), done.
Writing objects: 100% (74/74), 185.95 KiB | 4.77 MiB/s, done.
Total 74 (delta 20), reused 15 (delta 0)
 <-- Start deployment of xxx-app-staging -->
       Fetching source code
-----> Creating runtime …
Run Code Online (Sandbox Code Playgroud)

reactjs create-react-app

2
推荐指数
1
解决办法
3662
查看次数

在create-react-app上运行构建后的空白页

尝试在netlify上部署create-react-app,但是我的构建是空白页。我正在使用.env文件加载firebase api密钥,这是构建问题吗?

即使当我尝试在其计算机上的空白页上本地打开它并在控制台中输出错误:“使用源“ file:///event-app/static/js/main.108757a0.js加载失败””

package.json:https : //gist.github.com/Verthon/f82371ad2bb636b2e95c5b7697aa0bb5

?  event-app git:(master) ? npm run build

> event-app@0.1.0 build /home/jurr/Projects/event-app
> node scripts/build.js

Creating an optimized production build...
Compiled with warnings.

./src/components/Router.js
  Line 12:  'withFirebase' is defined but never used  no-unused-vars

./src/components/Firebase.js
  Line 21:  'Firebase' is defined but never used  no-unused-vars

Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.

File sizes after gzip:

  282.86 KB  build/static/js/main.108757a0.js
  3.1 KB     build/static/css/main.8e671453.css

Run Code Online (Sandbox Code Playgroud)

reactjs netlify create-react-app

2
推荐指数
5
解决办法
3728
查看次数