如何从 package-lock.json 中排除模块?
我需要排除特定模块,以便不在 package-lock.json 中进行版本控制。这可能吗?
我的问题是我有一个本地模块(打包在不同的项目中)。为了方便起见,我总是使用相同的名称导出此模块:localmodule-1.1.1.tgz
。
然后我将其导入到另一个项目中,如下所示:
...
"dependencies": {
"localmodule": "file:../LocalModule/dist/localmodule-1.1.1.tgz"
},
...
Run Code Online (Sandbox Code Playgroud)
每次我更改模块的内容时,导入该模块的项目都会因错误而中断Unhandled rejection Error: Integrity check failed
。校验和不匹配,因为内容已更改(校验和存储在 package-lock.json 中)。
是否可以不将此模块包含在 package-lock.json 中? 我想避免每次更改模块的任何内容时都更改模块的名称。
免责声明:我不是在谈论 package-lock.json 的版本控制。该文件将被版本控制。我只是想从文件本身的内容中排除特定模块。
我有一个枚举:
export enum ApiMessages {
logged_ok = 'Logged OK',
register_ok = 'Register OK'
}
Run Code Online (Sandbox Code Playgroud)
我有一个带有枚举作为参数的函数:
export function responseOK(message: ApiMessages, result ?: any): ApiResponse {
return {
"status": "ok",
"code": 200,
"messageId": ApiMessages[message], <-- KO TS7015
"message": message,
"result": result
};
}
Run Code Online (Sandbox Code Playgroud)
我正在这样调用函数:
responseOK(ApiMessages.logged_ok, {user: userRes})
Run Code Online (Sandbox Code Playgroud)
我试图将枚举键和枚举字符串值返回到响应,但出现TS错误:
TS7015:元素隐式地具有“ any”类型,因为索引表达式不是“ number”类型。
我有严格的TypeScript配置。不能添加excludeImplicitAnyIndexErrors。
TypeScript版本:2.9.2
我正在尝试为我的 react-native 项目重新创建 ios 和 android 文件夹。据我所知,这是通过命令完成的:
react-native eject
Run Code Online (Sandbox Code Playgroud)
但我收到错误:
error Unrecognized command "eject".
Run Code Online (Sandbox Code Playgroud)
我做错了什么?我应该如何重新创建 android 和 ios 文件夹?
react-native-cli: 2.0.1
我有一个在 GIT 存储库中版本化的 nodejs 项目。当我克隆项目时,包含 package-lock.json(应该是这样)但是当我执行“npm install”时出现错误Unhandled rejection Error: Integrity check failed
如果我删除 package-lock.json 一切正常
包.json:
"dependencies": {
"aws-sdk": "^2.258.1",
"localmodule": "file:../LocalModule/dist/localmodule-1.1.1.tgz"
},
"devDependencies": {
"@types/chai": "^4.1.4",
"@types/mocha": "^5.2.2",
"@types/node": "^10.3.2",
"@types/sinon": "^5.0.1",
"aws-sdk-mock": "^2.0.0",
"chai": "^4.1.2",
"merge2": "^1.2.2",
"mocha": "^5.2.0",
"nps": "^5.9.2",
"nps-utils": "^1.6.0",
"sinon": "^5.0.10",
"sinon-chai": "^3.1.0",
"ts-node": "^6.1.1",
"typescript": "^3.1.6"
}
Run Code Online (Sandbox Code Playgroud)
完整错误:
Unhandled rejection Error: Integrity check failed:from@0.1.7 extracted to /home/...
Wanted: sha512-atI2DklW/phzBW2RyPznpbepvl1aRh7Y0XHfguqv...
Found: sha512-9BeJ7UP5OY9cUDsNXlHaYL6Xqd1cARifioOEtF60...
at checksumError (/usr/lib/node_modules/npm/node_modules/cacache/lib/content/write.js:157:13)
at write (/usr/lib/node_modules/npm/node_modules/cacache/lib/content/write.js:35:22)
at putData …
Run Code Online (Sandbox Code Playgroud) 我有很长的文本需要在 Ionic 4 应用程序中翻译。我正在使用 Angx ngx-translate (@ngx-translate v11.0.1)。
为了提高可读性,我希望翻译成多行而不是一行。
我已经改变了我的 i18n json,从此(en-US.json):
"common-questions-content" : "<b>Question 1?</b> Answer 1 <br> <b>Question 2?</b> Answer 2 <b>Question 3?</b> Answer 3",
Run Code Online (Sandbox Code Playgroud)
对此:
"common-questions-content" : [
"<b>Question 1?</b> Answer 1 <br>",
"<b>Question 2?</b> Answer 2 <br>",
"<b>Question 3?</b> Answer 3"
],
Run Code Online (Sandbox Code Playgroud)
没想到这竟然有效!但是,它在数组的每个值之间放置逗号:
我在 app.component.ts 中加载翻译服务:
import {TranslateService} from '@ngx-translate/core';
...
private translateService: TranslateService,
...
this.translateService.use('en-US');
Run Code Online (Sandbox Code Playgroud)
最后我在我的 html 页面中使用它,如下所示:
{{ 'common_questions' | translate }}
Run Code Online (Sandbox Code Playgroud)
是否可以更改此行为并只显示所有不带逗号的文本?
我想使用字符串设置跟踪级别(因为我从环境变量获取级别)。
let env_log_level = std::env::var("LOG_LEVEL").unwrap();
tracing_subscriber::fmt()
.with_max_level(tracing::Level::DEBUG) // somehow use env_log_level here
.with_target(false)
.init();
Run Code Online (Sandbox Code Playgroud)
我想这应该是一种将字符串解析为 Level 对象的方法,但我不知道如何实现。