hardware-security-module 相关问题


将 Spring Security 5 迁移到 Spring Security 6 HttpSecurity 问题

Spring Security 6 中以下代码应该替代什么? http .authorizeRequests() .requestMatchers("/hub/**").access("hasPermission('SOME_LAYER', '')")...


无法解析包“notistack5”的条目。该包的 package.json 中指定的 main/module/exports 可能不正确

运行vite时,出现以下错误: 15:52:07 [vite] 内部服务器错误:无法解析条目 包裹...包裹可能有不正确 main/module/exports 在其


如何使用spring security 6为AuthenticationManager的参数2定义bean?

我是 Spring Security 6 的新手。当我尝试配置安全性时,出现此错误: ************************** 应用程序无法启动 ************************** 描述:


authorization_code 授权类型的 unsupported_grant_type 错误:Spring Security OAuth2

我正在尝试使用 Spring Security 通过 OpenID Connect 实现 OAuth2 授权服务器。 为此,我使用带有刷新令牌和 JWT 的授权代码流程。这是我的配置...


无法提取响应:在 springn oauth2client 代码中找不到适合响应类型的 HttpMessageConverter

我正在尝试实现 spring security oauth2client。 我使用 springboot 3。我也实现了 spring security oauth2 授权服务器。 当我启动客户端应用程序时,我得到


Spring Security 6 POST 请求未经permitAll()授权

我正在使用 Spring Boot 3、Spring Security 6。我的安全配置无法正常工作。我有 2 条路径,任何请求都应该被允许,而对于其他所有请求,都需要进行身份验证...


ASP.Net 表单 - Content-Security-Policy 随机数值不适用于内联脚本

net 空 webform 项目并添加 1 个按钮、1 个内联脚本(按钮中使用的 1 个函数)并为 Content-Security-Policy 设置声明 1 个元标记。 我的意图是想在我的...


Duo Security Admin API 用户请求在 Java 中使用失败

我正在使用 Duo Security Admin API。但是当我使用下面的代码调用 api 时,它显示: 获取用户请求因 HTTP 失败(响应代码:401) 这是我的java代码: 无效用户(){ // 双广告...


如何在Spring Security中检查每个请求的用户状态

我正在使用 spring security 并实现了 UserDetailsService ,它完美地处理了我的用户登录过程。 问题是这样的: 是否有一种标准方法可以从数据库中检查用户状态


如何让 VSCode 从代码所在位置运行你的代码

我在 Python 中不断收到 Module Not Found 错误,并通过打印 os.getcwd(),我发现 VSCode 似乎正在运行工作区文件夹(编辑器中的顶级文件夹)中的内容...


创建名为“springSecurityFilterChain”的 bean 时出错

我一直在关注Spring Security Reference,我只添加了这些类: @配置 @EnableWebMvcSecurity 公共类 WebSecurityConfig 扩展 WebSecurityConfigurerAdapter { @


如何使用u-boot mmc命令创建EMMC分区?

我正在使用 Raspberry PI Compute Module 4 进行开发。我的 RPI-cm4 具有板载 EMMC 8GB 内存。我们遵循以下布局 对于引导加载程序,我们使用 u-boot。 U-Boot> mmc 列表 mmcnr@7e3000...


Spring Security 循环依赖

我的 SecurityConfiguration 和 CustomAuthenticationFilter 之间存在循环依赖关系。我认为 AuthenticationManager 是问题所在,我无法解决它。 安全配置 @


在Ocaml中编译多文件项目,导致Unbound Module错误

上下文 我目前正在尝试学习 OCaml 的基础知识(通过 2022 年代码挑战的到来)。我的目标是仅使用 OCaml 标准库并编写我自己的 make 来获得基本知识 -


Spring security 6.2 JSESSIONID 未返回

我正在使用 Kotlin 创建一个 Spring Boot 应用程序。我已经将 WebSecurity 配置为: @配置 类安全配置{ @Autowired Lateinit var dataSource: 数据源 @值(...


/admin/v1/users 在 DUO Security Admin API 中给出 40103

我正在尝试使用它显示的 /admin/v1/users 创建 { “代码”:40103, "message":"请求凭证中的签名无效", “统计”:“失败” } 哈...


bean“mvcHandlerMappingIntrospectorRequestTransformer”无法注册。具有该名称的 bean 已被定义并覆盖 i

环境:Spring Boot 3.2.1、JDK 21、GraalVM、Spring Native、Spring Security。错误 微软Windows [版本10.0.22631.2861] (c) 微软公司。版权所有。 。 ____ ...


SSAS/Power BI 行级安全性

我一直在使用 radacad 创建的一些非常有用的文章(例如 https://radacad.com/dynamic-row-level-security-with-manager-level-access-in-power-bi),使我能够添加一些行级安全...


Spring Security 6 中 BCryptPasswordEncoder 注册和登录密码不匹配

这个问题我找了好久都没有解决,看了很多东西,还是不明白。 一般来说,我有一个用户注册表单(Thymeleaf),其中的数据传输到...


Websockets 和 Spring Boot Security 的错误 401

我正在使用 Spring Boot 3.1.0,我正在尝试在我的应用程序中实现一些 websockets。我正在按照互联网上的教程来实现它们并生成一些统一的测试以确保......


Spring Boot api 在多次成功的 200 响应后给出 403

我有一个 Spring Boot 应用程序,它使用 spring security 作为依赖项。我正在将 Spring boot 版本从 2.7.16 迁移到 3.2.1。在 2.7.16 版本中一切正常。但在 3.2.1 中,其余 API 都...


如何修复“在索引 0 处找到带有非文字参数的 fs.readFile”?

我正在尝试在 TypeScript 项目中添加 eslint-plugin-security。然而,对于这些代码 从 'fs' 导入 { Promise as fsp }; 从 'fs' 导入 fs; 从“路径”导入路径; 常量索引=等待...


在 Springdoc 中自动生成基于 Swagger 注释的描述

基本上我的问题与这个相同,但是针对Springdoc(而不是Springfox)。 简而言之,我有一个 Spring-boot 应用程序,并且我正在使用 spring-security @PreAuthorize 注释来保护我的一些......


配置 SAML2:绕过“InResponseTo”验证,同时保留 OpenSaml4AuthenticationProvider 中的默认设置

我有一个在 Nginx 和 Spring Security 后面运行的 Java 后端应用程序用于 SSO。我的后端应用程序缺乏记住 cookie 会话的机制,因为 SSO 请求可能由...发起


为什么 CORS 配置为允许任何访问,登录时仍然出现 401 Unauthorized 错误?

经过几天的尝试解决以下问题后,我对以下问题感到不知所措。 我构建这个项目的上下文是 React/Axios/Spring Boot 3/Spring Security 6。 我收到 401 CORS unauthor...


ESLint:解析错误:意外的标记:

大家好我正在将我的 vue3 项目从 js 迁移到 typescript,我遇到了这个问题: 这是我在 .vue 文件中的代码 const toto = (msg: string) => { </desc> <question vote="7"> <p>大家好,我正在将我的 vue3 项目从 js 迁移到 typescript,我遇到了这个问题:</p> <p><a href="https://i.stack.imgur.com/y5tG8.png" target="_blank"><img src="https://cdn.txt58.com/i/AWkuc3RhY2suaW1ndXIuY29tL3k1dEc4LnBuZw==" alt=""/></a></p> <p>这是我在 .vue 文件中的代码</p> <pre><code>&lt;script setup lang=&#34;ts&#34;&gt; const toto = (msg: string) =&gt; { console.log(msg) } &lt;/script&gt; </code></pre> <p>这是我的 eslintrc.js</p> <pre><code>module.exports = { &#39;env&#39;: { &#39;browser&#39;: true, &#39;es2021&#39;: true }, &#39;extends&#39;: [ &#39;eslint:recommended&#39;, &#39;plugin:vue/vue3-essential&#39; ], &#39;parserOptions&#39;: { &#39;ecmaVersion&#39;: 13, &#39;sourceType&#39;: &#39;module&#39; }, &#39;plugins&#39;: [ &#39;vue&#39; ], &#39;rules&#39;: { &#39;vue/multi-word-component-names&#39;: &#39;off&#39;, &#39;vue/object-curly-spacing&#39;: [2, &#39;always&#39;], &#39;vue/html-closing-bracket-spacing&#39;: [2, { &#39;selfClosingTag&#39;: &#39;always&#39; }], &#39;vue/max-attributes-per-line&#39;: [2, { &#39;singleline&#39;: { &#39;max&#39;: 1 }, &#39;multiline&#39;: { &#39;max&#39;: 1 } }], &#39;semi&#39;: [2, &#39;never&#39;] } } </code></pre> </question> <answer tick="true" vote="10"> <p>您需要配置 eslint 以支持 typescript,因为 eslint 不支持开箱即用。 首先,您需要安装<a href="https://www.npmjs.com/package/@typescript-eslint/parser" rel="nofollow noreferrer">@typescript-eslint/parser</a>,然后安装<a href="https://www.npmjs.com/package/@typescript-eslint/eslint-plugin" rel="nofollow noreferrer">@typescript-eslint/eslint-plugin</a>。 安装完这些后,请按如下方式更新您的配置 - </p> <pre><code>module.exports = { &#39;env&#39;: { &#39;browser&#39;: true, &#39;es2021&#39;: true, node: true }, &#39;extends&#39;: [ &#39;eslint:recommended&#39;, &#39;plugin:vue/vue3-essential&#39; ], &#39;parserOptions&#39;: { &#39;ecmaVersion&#39;: 12, &#39;sourceType&#39;: &#39;module&#39;, parser: &#39;@typescript-eslint/parser&#39; }, &#39;plugins&#39;: [ &#39;vue&#39;, &#39;@typescript-eslint&#39; ], &#39;rules&#39;: { &#39;vue/multi-word-component-names&#39;: &#39;off&#39;, &#39;vue/object-curly-spacing&#39;: [2, &#39;always&#39;], &#39;vue/html-closing-bracket-spacing&#39;: [2, { &#39;selfClosingTag&#39;: &#39;always&#39; }], &#39;vue/max-attributes-per-line&#39;: [2, { &#39;singleline&#39;: { &#39;max&#39;: 1 }, &#39;multiline&#39;: { &#39;max&#39;: 1 } }], &#39;semi&#39;: [2, &#39;never&#39;] } } </code></pre> </answer> <answer tick="false" vote="1"> <p>就我而言,问题是我使用解析器选项作为数组,而不是字符串:</p> <pre><code> parserOptions: { - parser: [&#39;@typescript-eslint/parser&#39;], + parser: &#39;@typescript-eslint/parser&#39;, }, </code></pre> </answer> <answer tick="false" vote="0"> <p>如果你在项目中同时使用 JS 和 TS,此配置有帮助</p> <pre><code> overrides: [ { files: [&#39;*.vue&#39;], parser: &#39;svelte-eslint-parser&#39;, parserOptions: { parser: { // Specify a parser for each lang. ts: &#39;@typescript-eslint/parser&#39;, js: &#39;espree&#39;, typescript: &#39;@typescript-eslint/parser&#39; } } } ], </code></pre> </answer> <answer tick="false" vote="-1"> <p>我在节点 v12.22.9 上遇到了这个问题。通过升级到 v14.21.2,我不再遇到解析错误。您可以使用命令升级/安装</p> <pre><code>nvm install v14.21.2 </code></pre> </answer> </body></html>


conda错误ssl证书:HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443

无论我做什么,我都会收到此错误 C:\Users\MyPc>conda update --all 解决环境:失败 CondaHTTPError:URL 的 HTTP 000 连接失败 无论我做什么,我都会收到此错误 C:\Users\MyPc>conda update --all Solving environment: failed CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/free/win-64/repodata.json.bz2> Elapsed: - An HTTP error occurred when trying to retrieve this URL. HTTP errors are often intermittent, and a simple retry will get you on your way. If your current network has https://www.anaconda.com blocked, please file a support request with your network engineering team. SSLError(MaxRetryError('HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443): Max retries exceeded with url: /pkgs/free/win-64/repodata.json.bz2 (Caused by SSLError("Can\'t connect to HTTPS URL because the SSL module is not available."))')) 我已经搜索了所有互联网,重新安装了 anaconda 并做了建议中的任何操作,但这个问题仍然存在。 Windows 10 C:\Users\MyPc>anaconda --version anaconda 命令行客户端(版本 1.7.2) C:\Users\MyPc>conda --version 康达 4.5.12 就我而言,当我尝试运行此命令时,我收到了此类错误消息 conda install tensorflow 这是错误消息 CondaSSLError:OpenSSL 似乎在此计算机上不可用。下载并安装软件包需要 OpenSSL。 异常:HTTPSConnectionPool(主机='repo.anaconda.com',端口=443):超过最大重试次数,网址:/pkgs/main/win-64/current_repodata.json(由SSLError(“无法连接到HTTPS URL”)引起因为 SSL 模块不可用。")) 这就是解决方案 步骤01 进入你的anaconda3的安装路径 步骤02 现在转到此文件路径 anaconda3\Library\bin 步骤03 现在选择这个 DLL 文件并复制它 libcrypto-1_1-x64.dll libssl-1_1-x64.dll 步骤04 之后转到此文件路径并将其粘贴到该文件夹内部 anaconda3\DLLs 这个命令对我有用: conda config --set ssl_verify false 我也遇到了同样的问题,解决这个问题的方法是安装早期的 32 位版本的 Conda。由于某种原因,较新的 64 位版本似乎容易出现此错误。您可以在这里找到 Conda 的早期版本: https://repo.continuum.io/archive/ 您应该搜索仅具有 x86 而不是 x86_64 的 Anaconda3 版本。 我也遇到了同样的问题,简单的解决方案是: 从开始菜单打开anaconda navigator,然后运行CMD.exe提示符,然后从那里安装,就是这样。 在 C:\Users\xyz 目录中创建一个名为 .condarc 的文件,其中包含以下内容 频道: 默认值 ssl_verify:假 然后尝试创建虚拟环境: conda create -n envname python=x.x anaconda 祝你好运!


使用python的mechanize自动网站登录

我正在尝试自动登录一个网站,该网站的登录表单具有以下 HTML 代码(摘录): 我正在尝试自动登录一个网站,其登录表单具有以下 HTML 代码(摘录): <tr> <td width="60%"> <input type="text" name="username" class="required black_text" maxlength="50" value="" /> </td> <td> <input type="password" name="password" id="password" class="required black_text" maxlength="50" value="" /> </td> <td colspan="2" align="center"> <input type="image" src="gifs/login.jpg" name="Login2" value="Login" alt="Login" title="Login"/> </td> </tr> 我正在使用python的mechanize模块进行网页浏览。以下是代码: br.select_form(predicate=self.__form_with_fields("username", "password")) br['username'] = self.config['COMMON.USER'] br['password'] = self.config['COMMON.PASSWORD'] try: request = br.click(name='Login2', type='image') response = mechanize.urlopen(request) print response.read() except IOError, err: logger = logging.getLogger(__name__) logger.error(str(err)) logger.debug(response.info()) print str(err) sys.exit(1) def __form_with_fields(self, *fields): """ Generator of form predicate functions. """ def __pred(form): for field_name in fields: try: form.find_control(field_name) except ControlNotFoundError, err: logger = logging.getLogger(__name__) logger.error(str(err)) return False return True return __pred 不知道我做错了什么...... 谢谢 该网站有可能在登录期间使用java脚本进行回发。我记得很清楚,对于 ASP .Net 站点,您需要获取隐藏表单字段,例如 VIEWSTATE 和 EVENTTARGET 并将它们发布到新 Page 。 您为什么不发送问题网站的链接?之后就变得相对容易弄清楚了 尝试使用 Selenium 和 PhantomJS from selenium import PhantomJS import platform if platform.system() == 'Windows': # .exe for Windows PhantomJS_path = './phantomjs.exe' else: PhantomJS_path = './phantomjs' service_args = [ # Proxy (optional) '--proxy=<>', '--proxy-type=http', '--ignore-ssl-errors=true', '--web-security=false' ] browser = PhantomJS(PhantomJS_path, service_args=service_args) browser.set_window_size(1280, 720) # Window size for screenshot (optional) login_url = "<url_here>" # Credentials Username = "<insert>" Password = "<insert>" # Login browser.get(login_url) browser.save_screenshot('login.png') print browser.current_url browser.find_element_by_id("<username field id>").send_keys(Username) browser.find_element_by_id("<password field id>").send_keys(Password) browser.find_element_by_id("<login button id>").click() print (browser.current_url) browser.get(scrape_url) print browser.page_source browser.quit() ''' python 和 pycharm 设置路径变量 点维辛检查 包管理器 python 如何安装新版本 python最新版本 - python 3.7.2 用户环境变量 蟒蛇 pyton 中的命令行 '''


防止打开的窗口覆盖 opener 的 `close` 方法

我有一个 test1.html 文件,仅包含以下代码: janela = window.open("http://localhost/test2.html","_blank","width=1000,height=400,left=600,top=0"); </...</desc> <question vote="1"> <p>我有一个 <pre><code>test1.html</code></pre> 文件,其中仅包含以下代码:</p> <pre><code>&lt;script&gt; janela = window.open(&#34;http://localhost/test2.html&#34;,&#34;_blank&#34;,&#34;width=1000,height=400,left=600,top=0&#34;); &lt;/script&gt; </code></pre> <p>上面的代码将打开窗口<pre><code>test2.html</code></pre>,其中包含以下代码:</p> <pre><code>&lt;script&gt; opener.window.janela.close = null; &lt;/script&gt; </code></pre> <p>现在,在窗口 <pre><code>test1.html</code></pre> 上,如果我尝试关闭刚刚使用 <pre><code>janela.close()</code></pre> 打开的窗口,我将无法这样做。</p> <p>我知道在 <pre><code>noopener</code></pre> 方法中使用 <pre><code>window.open</code></pre> 会阻止 <pre><code>test2.html</code></pre> 访问 <pre><code>test1.html</code></pre> 但是它也会阻止我在 <pre><code>test1.html</code></pre> 关闭 <pre><code>test2.html</code></pre>。</p> <p>那么我怎样才能可靠地打开 <pre><code>window</code></pre> 并能够在将来自信地关闭它?</p> <p><strong>根据@mplungjan</strong></p>进行编辑 <p>在@mplungjan的帮助下,我做到了:</p> <pre><code>myClose = window.close; janela = window.open(&#34;https://a2eestrutural.eng.br/?fdfk&#34;,&#34;_blank&#34;,&#34;width=1000,height=400,left=600,top=20&#34;); janela.myClose = window.myClose; </code></pre> <p>窗口打开后,我尝试执行<pre><code>janela.myClose();</code></pre>并收到此错误消息:</p> <pre><code>An attempt was made to break through the security policy of the user agent. </code></pre> <p>知道我该如何继续吗?</p> </question> <answer tick="false" vote="0"> <p>为什么要有这个代码?如果您可以控制打开的内容...</p> <p>无论如何,请在打开窗口的脚本之前尝试此操作</p> <pre><code>const myClose = window.close; const janela = window.open(&#34;http://localhost/test2.html&#34;,&#34;_blank&#34;,&#34;width=1000,height=400,left=600,top=0&#34;); .... janela.myClose() </code></pre> </answer> </body></html>


在发布为 npm 包之前使用 npm 链接测试组件时出现重复的 ReactJS 导入问题

我有一个像这样的简单组件。 从'react'导入React,{useState}; 函数 MyComponentWithState(props) { const [值,setValue] = useState(0); 返回 ( 我的价值... 我有一个像这样的简单组件。 import React, {useState} from 'react'; function MyComponentWithState(props) { const [value, setValue] = useState(0); return ( <p>My value is: {value}</p> ) } export default MyComponentWithState; 我想将它作为单独的包发布在 NPM 上。因此,为此我准备了 package.json 和 webpack.config.js,如下所示。 package.json: { "name": "try-to-publish", "version": "0.0.1", "description": "Just a test", "main": "build/index.js", "scripts": { "start": "webpack --watch", "build": "webpack" }, "author": { "name": "Behnam Azimi" }, "license": "ISC", "peerDependencies": { "react": "16.9.0", "react-dom": "16.9.0" }, "dependencies": { "react": "16.9.0", "react-dom": "16.9.0", "prop-types": "15.7.2", "react-scripts": "3.1.1", "webpack": "4.39.3" }, "devDependencies": { "@babel/core": "7.6.0", "@babel/plugin-proposal-class-properties": "7.5.5", "@babel/preset-env": "7.6.0", "@babel/preset-react": "7.0.0", "babel-loader": "8.0.6", "babel-plugin-transform-object-rest-spread": "6.26.0", "babel-plugin-transform-react-jsx": "6.24.1", "css-loader": "3.2.0", "node-sass": "4.12.0", "sass-loader": "8.0.0", "style-loader": "1.0.0", "webpack-cli": "3.3.8", "webpack-external-react": "^1.1.2" } } webpack.config.json: const path = require('path'); module.exports = { entry: './src/index.js', output: { path: path.resolve(__dirname, 'build'), filename: 'index.js', libraryTarget: 'commonjs2' }, module: { rules: [ { test: /\.(js|jsx)$/, exclude: /node_modules/, include: path.resolve(__dirname, 'src'), use: { loader: "babel-loader" } }, ] }, resolve: { alias: { 'react': path.resolve(__dirname, 'node_modules/react'), 'react-dom': path.resolve(__dirname, 'node_modules/react-dom'), } }, externals: { 'react': "commonjs react", 'react-dom': "commonjs react-dom" }, }; 这是我的 .babelrc: { "presets": [ "@babel/preset-env", "@babel/preset-react" ], "plugins": ["@babel/plugin-proposal-class-properties"] } 当我将组件发布到 NPM 并使用 `npm install 将其安装到我的另一个 ReactJs 项目中时,这些配置就像魅力一样,但我的观点是本地测试! 我想在发布之前测试这个组件/库。为此,我使用 npm link 功能将我的组件与我的主 ReactJS 项目链接起来。 正如您在上面看到的,我的组件是功能性的,我也使用了钩子。因此,当我将本地链接的库注入到我的主 ReactJs 项目中时,会遇到此错误, 无效的挂钩调用。钩子只能在函数组件的主体内部调用。发生这种情况可能是由于以下原因之一: 1.您的React和渲染器版本可能不匹配(例如React DOM) 2. 你可能违反了 Hooks 规则 3. 您可能在同一个应用程序中拥有多个 React 副本 我的问题与第三个原因有关。我的项目使用 ReactJs 并导入一次,我的组件也会导入 React!我的意思是在一个项目中两次 React 导入!. 我的 Webpack 配置中还有关于 react 和 react-dom 的 externals 配置。 我应该怎么做才能解决这个问题?我的错误在哪里? 更新: 我也尝试过 @sung-m-kim 和 @eddie-cooro 所说的,但没有成功!意思是,我更改了 package.json 并从 react 中删除了 react-dom 和 dependencies 并将它们添加到 devDpendencies。 我终于通过这些步骤解决了这个问题。 运行npm链接里面 <your-library-package>/node_modules/react 还有 运行npm链接里面 <your-library-package>/node_modules/react-dom 然后在 应用程序根目录中运行 npm link react 和 npm link react-dom 并且不要忘记将 React 和 React-dom 作为库中的外部对象保留 // webpack.config.js const externals = { "react": "react", "react-dom": "react-dom", } module.exports = { . . . externals } 我解决了我的问题。我使用 RollupJS 而不是 Webpack 作为捆绑工具进行捆绑。 这是我的rollup.config.js: import {uglify} from 'rollup-plugin-uglify' import babel from 'rollup-plugin-babel' export default { input: "./src/index.js", external: ['react', 'react-dom'], output: { name: 'test-lib', format: "cjs", }, plugins: [ babel({ exclude: "node_modules/**" }), uglify(), ], }; 和我的package.json: { "name": "test-lib", "version": "1.0.0", "main": "dist/test-lib.min.js", "scripts": { "build": "rollup -c -o dist/test-lib.min.js" }, "author": "Behnam Azimi", "license": "ISC", "peerDependencies": { "react": "^16.9.0", "react-dom": "^16.9.0" }, "devDependencies": { "@babel/core": "^7.6.0", "@babel/preset-env": "^7.6.0", "@babel/preset-react": "^7.0.0", "rollup": "^1.21.4", "rollup-plugin-babel": "^4.3.3", "rollup-plugin-commonjs": "^10.1.0", "rollup-plugin-uglify": "^6.0.3" } } 经过这些更改,npm link在我的ReactJS(Hooks)项目中真正发挥了作用。 请注意,这只是一个简单的 Rollup 配置来展示我的解决方案,您可以在配置中添加多种内容,例如热重载、样式加载器和许多其他插件。 仅在 package.json 的 react 部分(而不是 react-native)内设置 peerDependencies 和 dependencies 包。另外,对于本地开发(当您的包未包含在任何其他 React 项目中并且您想在本地运行它时),您可以使用 devDependencies 字段。 我在打字稿反应项目中解决了这个问题。 可能,当使用 npm link 时,请使用主应用程序项目和组件项目中的 react。 因此,在您的 package.json 中从 react 和/或 dependencies 中删除 devDependencies 检查答案:https://stackoverflow.com/a/62807950/5183591 我也有同样的问题。 就我而言,我开发了一些 UI 组件作为包,其中有一个包含 React 应用程序的示例文件夹,用于创建 React 应用程序。 问题是,当我使用 npm i ../ 将包安装到示例应用程序中时,它会将包中的所有文件安装到示例应用程序中,包括 node_modules 文件夹。由于我已经安装了 react 和 react-dom 作为对等依赖项,示例应用程序现在有两个不同的 React 副本。 从包中删除 node_module 文件夹并重新安装包再次解决了我的问题。


© www.soinside.com 2019 - 2024. All rights reserved.