我有一个使用两台不同笔记本电脑进行的项目。有时我会向我的项目添加额外的包,所以我必须使用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
有时会添加有时会^
完全删除插入符 ( ) …
如果,module1依赖于button-component@1.0.2
module2 依赖于button-component@1.5.0
最终捆绑包中加载了哪个版本的按钮组件?
我们可以采取哪些步骤来避免最终构建中的重复模块?
我有我的全局 Angular CLI 版本(13.0.1),项目中的本地版本是(10.2.3)。\n一切都很好,我对一些组件做了一些更改(我没有触及 package.json)并且当我运行管道(bitbucket 管道)时,我在构建步骤中遇到此错误:
\nERROR 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) 当我尝试使用 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) 您好,我尝试将 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) 我有一个现有的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) 我刚刚对我的存储库进行了干净的克隆,npm install
然后pod install
在ios/
目录中进行了克隆。这导致 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
。
当我尝试安装 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) 我正在实现 Rust Cargo 版本要求。一般来说,我很难理解指定的插入符要求。我发现package.json 中的 tilde(~) 和 caret(^) 有什么区别?,但是这个问题是关于 npm 版本要求的,我不确定它是否与 Rust Cargo 版本要求相同。
\n在https://doc.rust-lang.org/cargo/reference/specifying-dependency.html#caret-requirements,我读到:
\n\n\nCaret 要求允许 SemVer 兼容更新到指定版本。如果新版本号不修改主要、次要、补丁分组中最左边的非零数字,则允许更新。在这种情况下,如果我们运行,如果是最新版本,
\ncargo update -p time
cargo 应该将我们更新到版本,但不会将我们更新到。相反,如果我们将版本字符串指定为,则货物应该更新为(如果它是最新版本),而不是。该版本不被视为与任何其他版本兼容。0.1.13
0.1.z
0.2.0
^1.0
1.1
1.y
2.0
0.0.x
\n\n以下是插入符要求及其允许的版本的更多示例:
\n
\nRun Code Online (Sandbox Code Playgroud)\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
此兼容性约定与 SemVer 的不同之处在于它对待之前版本的方式
1.0.0
。虽然 …
我在生产环境中的 React 应用程序中遇到此错误:
TypeError: Cannot read properties of null (reading 'useRef')
启用了 sourcemap,它在react.production.min.js中显示错误
奇怪的是,我只在特定路线上得到这个。所有其他路线都工作正常(即使我useRef
在多个文件中使用 s )。
由于本地构建工作正常,我无法在本地重现该问题。
我尝试了以下操作:
node_modules
在生产机器上重新安装我正在使用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) angular ×3
npm ×3
reactjs ×3
node.js ×2
npm-install ×2
amazon-s3 ×1
bitbucket ×1
cocoapods ×1
composer-php ×1
d3.js ×1
docker ×1
javascript ×1
laravel ×1
material-ui ×1
nginx ×1
react-native ×1
rollup ×1
rust ×1
rust-cargo ×1
typescript ×1
webpack ×1