小编cri*_*ari的帖子

打字稿:调试失败。错误表达式:传递给“ts.resolveTypeReferenceDirective”的非字符串值

我有一个npm不久前构建的命令行应用程序,它运行良好。现在我已经更新了它,并且由于这段时间内打字稿版本的变化,当我想运行这个包时,我收到一个错误,其中显示:

Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.
Run Code Online (Sandbox Code Playgroud)

这是package.json文件:

{
  "name": "initialiseur",
  "version": "4.0.4",
  "main": "src index.ts",
  "author": "@crispengari",
  "license": "MIT",
  "bin": "src/index.ts",
  "description": "THIS IS A BOILER PLATE THAT INITIALIZE A NODE EXPRESS BACKEND FOR TYPESCRIPT AND JAVASCRIPT",
  "scripts": {
    "watch": "tsc -w",
    "start": "ts-node src/index.ts",
    "dev": "nodemon dist/index.ts",
    "start:fast": "tsnd --respawn src/index.ts" …
Run Code Online (Sandbox Code Playgroud)

javascript node.js npm typescript

59
推荐指数
6
解决办法
5万
查看次数

Pytorch:运行时错误:结果类型 Float 无法转换为所需的输出类型 Long

我有一个如下所示的模型:

IMG_WIDTH = IMG_HEIGHT = 224

class AlexNet(nn.Module):
  def __init__(self, output_dim):
    super(AlexNet, self).__init__()
    self._to_linear = None
    self.x = torch.randn(3, IMG_WIDTH, IMG_HEIGHT).view(-1, 3, IMG_WIDTH, IMG_HEIGHT)
    self.features = nn.Sequential(
        nn.Conv2d(3, 64, 3, 2, 1), # in_channels, out_channels, kernel_size, stride, padding
        nn.MaxPool2d(2),
        nn.ReLU(inplace=True),
        nn.Conv2d(64, 192, 3, padding=1),
        nn.MaxPool2d(2),
        nn.ReLU(inplace=True), 
        nn.Conv2d(192, 384, 3, padding=1),
        nn.MaxPool2d(2),
        nn.ReLU(inplace=True), 
        nn.Conv2d(384, 256, 3, padding=1),
        nn.MaxPool2d(2),
        nn.ReLU(inplace=True),
        nn.Conv2d(256, 512, 3, padding=1),
        nn.ReLU(inplace=True),
        nn.Conv2d(512, 256, 3, padding=1),
        nn.MaxPool2d(2),
        nn.ReLU(inplace=True)
  )
    self.conv(self.x)
    self.classifier = nn.Sequential(
        nn.Dropout(.5),
        nn.Linear(self._to_linear, 4096),
        nn.ReLU(inplace=True),
        nn.Dropout(.5),
        nn.Linear(4096, …
Run Code Online (Sandbox Code Playgroud)

python deep-learning pytorch

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

找不到模块“firebase”或其相应的类型声明。反应 + TypeScript + Firebase

我想将我一月份从事的 React 项目更改为使用 Typescript。我安装了所有类型和软件包,唯一给我带来问题的文件是该firebase文件。

这就是我当时使用的东西js

import firebase from "firebase";
import "firebase/storage";
import "firebase/auth";
import "firebase/firestore";
import dotenv from "dotenv";

dotenv.config();

const firebaseConfig = {
  apiKey: process.env.API_KEY,
  authDomain: process.env.AUTH_DOMAIN,
  projectId: process.env.PROJECT_ID,
  storageBucket: process.env.STORAGE_BUCKET,
  messagingSenderId: process.env.MESSAGING_SENDER_ID,
  appId: process.env.APP_ID,
  measurementId: process.env.MEASUREMENT_ID,
};
const app =
  firebase.apps.length > 0
    ? firebase.app()
    : firebase.initializeApp(firebaseConfig);

const auth = app.auth();
const db = app.firestore();
const storage = app.storage();
const timestamp = firebase.firestore.FieldValue.serverTimestamp();

const EmailProvider = new firebase.auth.EmailAuthProvider();
const _ = {
  auth,
  db, …
Run Code Online (Sandbox Code Playgroud)

firebase typescript firebase-realtime-database create-react-app google-cloud-firestore

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

ValidationError:无效的配置对象。Webpack 已使用与 API 架构不匹配的配置对象进行初始化。Next.js

我曾经create-next-app创建过 next.js 项目样板。但我一运行就npm run dev收到错误:

ValidationError: Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
 - configuration[0].node should be one of these:
   false | object { __dirname?, __filename?, global? }
   -> Include polyfills or mocks for various node stuff.
   Details:
    * configuration[0].node has an unknown property 'fs'. These properties are valid:
      object { __dirname?, __filename?, global? }
      -> Options object for node compatibility features.
    * configuration[0].node has …
Run Code Online (Sandbox Code Playgroud)

javascript node.js webpack next.js

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

无法从 keras.optimizer 安装 Adam

昨天在 google colab 上工作,一切正常。但现在我在尝试导入 Adam 时遇到了问题。

这就是我尝试导入的内容

from keras.optimizers import Adam, SGD, RMSprop
Run Code Online (Sandbox Code Playgroud)

这就是我得到的

ImportError                               Traceback (most recent call last)
<ipython-input-1-36a1fe725448> in <module>()
     30 from keras.layers import GlobalAveragePooling2D
     31 from keras.layers import BatchNormalization, Activation, MaxPooling2D
---> 32 from keras.optimizers import Adam, SGD, RMSprop

ImportError: cannot import name 'Adam' from 'keras.optimizers' (/usr/local/lib/python3.7/dist-packages/keras/optimizers.py)

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common …
Run Code Online (Sandbox Code Playgroud)

python keras

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

TypeORM/MySQL:无法删除或更新父行:外键约束失败

comments我和之间有实体关系posts _many-to-one_。我正在使用typeormtypegraphql

这是我的帖子实体:

@ObjectType()
@Entity()
export class Post extends BaseEntity {
  constructor(input: InputI) {
    super();
    this.caption = input?.caption;
    this.imageURL = input?.imageURL;
    this.status = input?.status;
    this.user = input?.user;
  }

  @Field(() => Int)
  @PrimaryGeneratedColumn({ type: "int" })
  id: number;

  @Field(() => String, { nullable: true })
  @Column({ type: "text", nullable: true })
  caption?: string;

  @Field(() => String, { nullable: true })
  @Column({ type: "text", nullable: true })
  imageURL?: string;

  @Field(() => String, { nullable: true }) …
Run Code Online (Sandbox Code Playgroud)

mysql node.js typescript typeorm

4
推荐指数
1
解决办法
5201
查看次数

Next.js:React Apollo 客户端不发送 cookie?

graphql我在我的应用程序上使用 Apollo Client 作为客户端next.js,以下是为我创建客户端的函数:

let client: ApolloClient<any>;

export const __ssrMode__: boolean = typeof window === "undefined";
export const uri: string = "http://localhost:3001/graphql";

const createApolloClient = (): ApolloClient<any> => {
  return new ApolloClient({
    credentials: "include",
    ssrMode: __ssrMode__,
    link: createHttpLink({
      uri,
      credentials: "include",
    }),
    cache: new InMemoryCache(),
  });
};
Run Code Online (Sandbox Code Playgroud)

令人惊讶的是,当我对 graphql 服务器进行更改时,我能够设置 cookie,但是我无法从客户端获取 cookie。可能是什么问题?

express apollo graphql server-side-rendering next.js

0
推荐指数
1
解决办法
1420
查看次数