尝试 npm 安装一个我刚刚拉下的存储库,我得到了与许多其他人相同的错误:
npm ERR! gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
所以我在我的 wsl2 实例中安装了 python 并重新启动了我的 shell,得到了同样的错误。然后我就跟着跑了
whereis python
输出如下:
python: /usr/bin/python3.8 /usr/bin/python3.8-config /usr/lib/python3.8 /usr/lib/python3.9 /usr/lib/python2.7 /etc/python3.8 /usr/local/lib/python3.8 /usr/include/python3.8 /mnt/c/Python39/python.exe /mnt/c/Python39/python3.dll /mnt/c/Python39/python39.dll /mnt/c/Users/ethan/AppData/Local/Microsoft/WindowsApps/python.exe /mnt/c/Users/ethan/AppData/Local/Microsoft/WindowsApps/python3.exe
Run Code Online (Sandbox Code Playgroud)
所以我跑了
npm config set python /usr/bin/python3.8
现在,当我尝试再次安装时,出现不同的错误
npm ERR! gyp ERR! stack Error: Command failed: /usr/bin/python3.8 -c import sys; print "%s.%s.%s" % sys.version_info[:3];
我不知道从这里去哪里,因为显然没有其他人遇到过这个错误
我目前正在为 Angular 4 应用程序制定货币格式化程序指令。在解析中去掉数字和小数以外的所有内容,并以字符串化的浮点数结束,但我需要它作为浮点数返回,以便我可以用它进行数学运算。
parse(value: string, fractionSize: number = 2): number {
let val = value.replace(/([^0-9.])+/ig, '');
let [ integer, fraction = "" ] = (val || "").split(this.DECIMAL_SEPARATOR);
integer = integer.replace(new RegExp(this.THOUSANDS_SEPARATOR, "g"), "");
fraction = parseInt(fraction, 10) > 0 && fractionSize > 0
? this.DECIMAL_SEPARATOR + (fraction + PADDING).substring(0, fractionSize)
: "";
let result = `${integer}${fraction}`;
// at this point result = "100.55";
result = parseFloat(result); // this refuses to compile saying "Type 'number' is not assignable ? to …Run Code Online (Sandbox Code Playgroud) 我正在 wsl2 中的 .net core 5 中开发 api,并按照所有文档安装实体框架核心工具。
当我跑步时
dotnet tool list -g
Run Code Online (Sandbox Code Playgroud)
它打印
Package Id Version Commands
--------------------------------------
dotnet-ef 5.0.7 dotnet-ef
Run Code Online (Sandbox Code Playgroud)
但当我跑步时
dotnet ef
Run Code Online (Sandbox Code Playgroud)
或其任何子命令,我明白了
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET program, but dotnet-ef does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not …Run Code Online (Sandbox Code Playgroud) 我正在尝试列出输入,我无法编译ngFor.
<div *ngFor="let q of questions; let i = index" class="col-3">
<div class="group">
<input [(ngModel)]="q" [class.ng-not-empty]="q.length > 0">
<span class="bar"></span>
<label>Question {{i}}</label>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我的定义如下:
questions: string[];
constructor() {
this.questions = ['blah', 'blah', 'blah'];
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
ERROR in : Error: Cannot assign to a reference or variable!
Run Code Online (Sandbox Code Playgroud)
如果我删除了它的索引定义,我已经尝试了以下所有方法:
*ngfor="let q of questions | index as i"
*ngfor="let q of questions; index as i"
Run Code Online (Sandbox Code Playgroud)