在我的react应用程序中,我正在导入一个模块,如下所示:
import { isValidAddress } from 'orbit-db';
Run Code Online (Sandbox Code Playgroud)
一些依赖isValidAddress要求multicodec/src/base-table(见本线)。
但是,开玩笑给出以下错误:
Configuration error:
Could not locate module multicodec/src/base-table mapped as:
/Users/h/Documents/code/orbit-db-time-machine/src/base-table.
Please check your configuration for these entries:
{
"moduleNameMapper": {
"/src\/(.*)$/": "/Users/h/Documents/code/orbit-db-time-machine/src/$1"
},
"resolver": null
}
Run Code Online (Sandbox Code Playgroud)
我认为这之所以发生是因为开玩笑的依赖性规则"/src\/(.*)$/"是将其中包含的所有路径重写src为<rootDir>/src,即使它们来自npm模块。
我试图通过将以下配置添加到我的服务器来解决此问题package.json:
"jest": {
"moduleNameMapper": {
"/multicodec\/(.*)$/": "<rootDir>/node_modules/multicodec/$1"
}
}
Run Code Online (Sandbox Code Playgroud)
但是,这并没有改变错误。我能够删除错误的唯一方法是删除我的import语句-但是,这在我的代码中是必需的。
注意:该代码在我的react应用中运行时有效,仅在我开玩笑时才会中断。
编辑:我已经设法通过将模型更改为此来开始抛出错误:
class User < ApplicationRecord
has_secure_password
has_attached_file :avatar,
:path => ":rails_root/public/system/:attachment/:id/:basename_:style.:extension",
:url => "/system/:attachment/:id/:basename_:style.:extension",
:styles => {
:thumb => ['100x100#', :jpg, :quality => 70],
:preview => ['480x480#', :jpg, :quality => 70],
:large => ['600>', :jpg, :quality => 70],
:retina => ['1200>', :jpg, :quality => 30]
},
:convert_options => {
:thumb => '-set colorspace sRGB -strip',
:preview => '-set colorspace sRGB -strip',
:large => '-set colorspace sRGB -strip',
:retina => '-set colorspace sRGB -strip -sharpen 0x0.5'
}
validates_attachment :avatar,
:presence => …Run Code Online (Sandbox Code Playgroud) 在关于 SFINAE 的 cppreference 文章中,我遇到了这个我不明白的语法:
template <int I> void div(char(*)[I % 2 == 0] = 0) {
// this overload is selected when I is even
}
template <int I> void div(char(*)[I % 2 == 1] = 0) {
// this overload is selected when I is odd
}
Run Code Online (Sandbox Code Playgroud)
我知道它是一个模板函数声明,但我不明白参数的含义。特别是,什么是方括号char(*)[I % 2 == 0] = 0,为什么它等于 0?