相关疑难解决方法(0)

为什么 `npm install` 在版本号中添加/删除插入符 (^)?

我有一个使用两台不同笔记本电脑进行的项目。有时我会向我的项目添加额外的包,所以我必须使用npm install <package-name>(废话)。当我这样做时,我git push会更新新的package.json文件package-lock.json,当我切换计算机时,我必须进行git pull这些更改,然后npm install再次运行以将该包传输到另一台计算机上。

^我最近注意到并开始关心一台笔记本电脑不断在每个软件包版本号的开头添加插入符 ( )。例如:

一台计算机将软件包版本号设置为如下所示:

"regexpu-core": {
  "version": "1.0.0",
  "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-1.0.0.tgz",
  "integrity": "sha1-hqdj9Y7k18L2sQLkdkBQ3n7ZDGs=",
  "requires": {
    "regenerate": "1.4.0",
    "regjsgen": "0.2.0",
    "regjsparser": "0.1.5"
  }
},
Run Code Online (Sandbox Code Playgroud)

其他设置包版本#s如下所示:

"regexpu-core": {
  "version": "1.0.0",
  "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-1.0.0.tgz",
  "integrity": "sha1-hqdj9Y7k18L2sQLkdkBQ3n7ZDGs=",
  "requires": {
    "regenerate": "^1.2.1",
    "regjsgen": "^0.2.0",
    "regjsparser": "^0.1.4"
  }
},
Run Code Online (Sandbox Code Playgroud)

我知道插入符 ( ^) 意味着版本不是 100% 精确,但我试图找出为什么我的不同笔记本电脑为软件包版本创建不同的格式!我检查了这个问题~,其中对和之间的差异有一些很好的解释^,但我没有找到任何解释为什么npm有时会添加有时会^完全删除插入符 ( ) …

npm npm-install

7
推荐指数
1
解决办法
6268
查看次数

像 webpack、rollup 这样的模块打包器如何处理同一依赖项的两个不同版本?

如果,module1依赖于button-component@1.0.2

module2 依赖于button-component@1.5.0

最终捆绑包中加载了哪个版本的按钮组件?

我们可以采取哪些步骤来避免最终构建中的重复模块?

javascript rollup reactjs webpack

7
推荐指数
1
解决办法
1200
查看次数

为什么@angular/core/core没有导出成员“??FactoryDe​​claration”。构建项目时抛出错误?

我有我的全局 Angular CLI 版本(13.0.1),项目中的本地版本是(10.2.3)。\n一切都很好,我对一些组件做了一些更改(我没有触及 package.json)并且当我运行管道(bitbucket 管道)时,我在构建步骤中遇到此错误:

\n
ERROR in node_modules/ngx-file-drag-drop/lib/ngx-file-drag-drop/ngx-file-drag-drop.component.d.ts:45:21 - error TS2694: Namespace '"/opt/atlassian/pipelines/agent/build/new-client/node_modules/@angular/core/core"' has no exported member '\xc9\xb5\xc9\xb5FactoryDeclaration'.\n45     static \xc9\xb5fac: i0.\xc9\xb5\xc9\xb5FactoryDeclaration<NgxFileDragDropComponent, never>;\n                       ~~~~~~~~~~~~~~~~~~~~\nnode_modules/ngx-file-drag-drop/lib/ngx-file-drag-drop/ngx-file-drag-drop.component.d.ts:46:21 - error TS2694: Namespace '"/opt/atlassian/pipelines/agent/build/new-client/node_modules/@angular/core/core"' has no exported member '\xc9\xb5\xc9\xb5ComponentDeclaration'.\n46     static \xc9\xb5cmp: i0.\xc9\xb5\xc9\xb5ComponentDeclaration<NgxFileDragDropComponent, "ngx-file-drag-drop", never, { "disabled": "disabled"; "multiple": "multiple"; "displayFileSize": "displayFileSize"; "borderColor": "activeBorderColor"; "accept": "accept"; "emptyPlaceholder": "emptyPlaceholder"; }, { "valueChanged": "valueChanged"; }, never, never>;\n                       ~~~~~~~~~~~~~~~~~~~~~~\nnode_modules/ngx-file-drag-drop/lib/byte.pipe.d.ts:7:21 - error TS2694: Namespace '"/opt/atlassian/pipelines/agent/build/new-client/node_modules/@angular/core/core"' has no exported member '\xc9\xb5\xc9\xb5FactoryDeclaration'.\n7     static \xc9\xb5fac: i0.\xc9\xb5\xc9\xb5FactoryDeclaration<BytePipe, never>;\n                      ~~~~~~~~~~~~~~~~~~~~\nnode_modules/ngx-file-drag-drop/lib/byte.pipe.d.ts:8:22 - error …
Run Code Online (Sandbox Code Playgroud)

bitbucket node.js npm typescript angular

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

安装Material UI时提示一系列错误?

当我尝试使用 npm install @material-ui/core 安装 Material UI 时,提示我很多错误:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: portfolio@0.1.0
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR!   react@"^17.0.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0" from @material-ui/core@4.11.0
npm ERR! node_modules/@material-ui/core
npm ERR!   @material-ui/core@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command …
Run Code Online (Sandbox Code Playgroud)

reactjs material-ui

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

Docker 构建在 npm install 时失败

您好,我尝试将 docker 与 Angular 应用程序一起使用,但在 npm install 时失败,而当我运行 npm install 时,它在“本地”安装时失败,但没有收到这些依赖项错误/警告。

这是 docker build 的错误日志:

 > [node 4/6] RUN npm install:
#12 9.943 npm notice
#12 9.943 npm notice New patch version of npm available! 7.5.1 -> 7.5.2
#12 9.944 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.5.2>
#12 9.944 npm notice Run `npm install -g npm@7.5.2` to update!
#12 9.944 npm notice
#12 9.950 npm ERR! code ERESOLVE
#12 9.956 npm ERR! ERESOLVE unable to resolve dependency tree
#12 9.956 npm ERR!
#12 …
Run Code Online (Sandbox Code Playgroud)

nginx npm docker angular

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

UNMET PEER DEPENDENCY D3.js和Angular 2

我有一个现有的Angular 2项目,我正在尝试将一些D3.js集成到我的项目中.我是Angular的新手,这将是我第一次使用D3.我将关注本教程:https://keathmilligan.net/create-reusable-chart-components-with-angular-2-and-d3-js-version-4/

我正在运行命令npm install --save d3,我得到:

??? UNMET PEER DEPENDENCY @angular/compiler@2.2.3
??? UNMET PEER DEPENDENCY @angular/compiler-cli@2.2.3
??? UNMET PEER DEPENDENCY @angular/core@2.2.3
??? d3@4.4.1
Run Code Online (Sandbox Code Playgroud)

...然后

npm WARN @ngtools/webpack@1.2.1 requires a peer of @angular/compiler@^2.3.1 but none was installed.
npm WARN @ngtools/webpack@1.2.1 requires a peer of @angular/compiler-cli@^2.3.1 but none was installed.
npm WARN @ngtools/webpack@1.2.1 requires a peer of @angular/core@^2.3.1 but none was installed.
npm WARN @ngtools/webpack@1.2.1 requires a peer of @angular/tsc-wrapped@^0.5.0 but none was installed.
npm WARN tslint-loader@2.1.5 …
Run Code Online (Sandbox Code Playgroud)

node.js d3.js npm-install angular

5
推荐指数
1
解决办法
1405
查看次数

React Native:Pod 安装导致 podfile.lock 中的版本与 package.json 不同

我刚刚对我的存储库进行了干净的克隆,npm install然后pod installios/目录中进行了克隆。这导致 my 发生变化Podfile.lock,它似乎已将几个模块升级到比package.json相应模块中指定的版本更新的版本,例如:

Podfile.lock:

-  - react-native-webview (8.1.0):
+  - react-native-webview (8.2.1):
Run Code Online (Sandbox Code Playgroud)

包.json:

"react-native-webview": "^8.1.0",
Run Code Online (Sandbox Code Playgroud)

我想了解为什么会发生这种情况以及这是否是一个问题。我会避免这种情况,但我不能这样做npm run ios,因为它说存在版本问题,我必须运行pod install

cocoapods react-native

5
推荐指数
1
解决办法
2180
查看次数

当我尝试安装 composer League/flysystem-aws-s3-v3 时出现错误

当我尝试安装 composer League/flysystem-aws-s3-v3 时出现错误
我的线路:composer require League/flysystem-aws-s3-v3
我使用 Laravel 8 和 php 7.3
我还测试了删除 composer.lock

已经有人修好了?


    Your requirements could not be resolved to an installable set of packages.
    
      Problem 1
        - league/flysystem-aws-s3-v3[2.0.0, ..., 2.x-dev] require league/flysystem ^2.0.0 -> found league/flysystem[2.0.0-alpha.1, ..., 2.x-dev] but the package is fixed to 1.1.3 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
        - league/flysystem-aws-s3-v3[2.0.0-alpha.1, ..., 2.0.0-alpha.2] require league/flysystem …
Run Code Online (Sandbox Code Playgroud)

amazon-s3 amazon-web-services laravel composer-php

5
推荐指数
3
解决办法
5527
查看次数

Rust Cargo 中插入符号版本约束意味着什么?

我正在实现 Rust Cargo 版本要求。一般来说,我很难理解指定的插入符要求。我发现package.json 中的 tilde(~) 和 caret(^) 有什么区别?,但是这个问题是关于 npm 版本要求的,我不确定它是否与 Rust Cargo 版本要求相同。

\n

https://doc.rust-lang.org/cargo/reference/specifying-dependency.html#caret-requirements,我读到:

\n
\n

Caret 要求允许 SemVer 兼容更新到指定版本。如果新版本号不修改主要、次要、补丁分组中最左边的非零数字,则允许更新。在这种情况下,如果我们运行,如果是最新版本, cargo update -p timecargo 应该将我们更新到版本,但不会将我们更新到。相反,如果我们将版本字符串指定为,则货物应该更新为(如果它是最新版本),而不是。该版本不被视为与任何其他版本兼容。0.1.130.1.z0.2.0^1.01.11.y2.00.0.x

\n
\n
\n

以下是插入符要求及其允许的版本的更多示例:

\n
\n
\n
^1.2.3  :=  >=1.2.3, <2.0.0\n^1.2    :=  >=1.2.0, <2.0.0\n^1      :=  >=1.0.0, <2.0.0\n^0.2.3  :=  >=0.2.3, <0.3.0\n^0.2    :=  >=0.2.0, <0.3.0\n^0.0.3  :=  >=0.0.3, <0.0.4\n^0.0    :=  >=0.0.0, <0.1.0\n^0      :=  >=0.0.0, <1.0.0\n
Run Code Online (Sandbox Code Playgroud)\n

此兼容性约定与 SemVer 的不同之处在于它对待之前版本的方式1.0.0。虽然 …

rust rust-cargo

5
推荐指数
1
解决办法
1590
查看次数

ReactJS:类型错误:无法读取 null 的属性(读取“useRef”)

我在生产环境中的 React 应用程序中遇到此错误:
TypeError: Cannot read properties of null (reading 'useRef')
启用了 sourcemap,它在react.production.min.js中显示错误

奇怪的是,我只在特定路线上得到这个。所有其他路线都工作正常(即使我useRef在多个文件中使用 s )。

由于本地构建工作正常,我无法在本地重现该问题。

我尝试了以下操作:

  1. 恢复到之前的工作提交。
  2. node_modules在生产机器上重新安装
  3. 从 Yarn 切换到 NPM

我正在使用express 来托管静态构建文件。这是代码:

const helmet = require('helmet');
const path = require('path');
const app = express();
const fs = require('fs');

app.disable('x-powered-by');
app.use(helmet.frameguard({ action: 'DENY' }));
app.use(express.static(__dirname));

app.get('*', function (req, res) {
    res.sendFile(path.join(__dirname, 'index.html'), {
        maxAge: 86400000,
    });
});
app.listen(process.env.PORT || 8080, function () {
    console.log(`Frontend start on http://localhost:8080`);
});
Run Code Online (Sandbox Code Playgroud)

编辑:反应组件:

import React, { useRef …
Run Code Online (Sandbox Code Playgroud)

reactjs

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