我一直试图为“react”npm模块编写一个自定义声明文件,但无法让编译器将我的声明文件解析为该模块。
当我执行import {DateRangePicker} from 'react-dates'时,会得到以下错误:
找不到模块“反应日期”的声明文件。'absolute_path/src/node_modules/react-dates/index.js‘隐式地具有“任意”类型。
我的声明文件位于路径‘@type/ and date/index.d.ts’中,如下所示:
import * as React from 'react';
decla
我正在使用react和npm组件包创建一个chrome扩展。我试图在页面上显示一条错误消息。当我触发错误消息组件时,我得到了一个错误。
这是错误:-
Error: Minified React error #130; visit https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=undefined&args[]= for the full message or use the non-minified dev environment for full errors and additional he
以下是使用非缺省导出的两个示例。第一种使用commonjs语法,第二种使用es6。为什么第一个例子可以工作,而第二个不行?
// commonjs --- works!
var ReactRouter = require('react-router')
var Link = ReactRouter.Link
// es6 --- doesn't work!
import ReactRouter from 'react-router'
var Link = ReactRouter.Link
我知道我可以使用import { Link } from
我在类型记录中使用React,但不能与commonjs以外的模块一起使用React。
我首先安装了react-bootstrap包:
$ npm i react-bootstrap
然后编写使用它的代码,例如,
// src/index.tsx
import { Button } from 'react-bootstrap';
但是,当我在谷歌上搜索这个问题时,npx tsc编译它得到了一个错误Cannot find module 'react-bootstrap' or its corresponding type declarations.,我发现react
我有一个包含多个react组件的库,并且我想使该库成为可树抖动的库,以便在导入像这样的组件时
import { Checkbox } from 'my-react-components'
我没有导入整个捆绑包。
我的index.js看起来像这样
export { default as Button } from './components/Button'
export { default as Checkbox } from './components/Checkbox'
export { default as FlexView } from &
我想将类型记录react作为组件捆绑到ES模块或UMD中。但是生成的ES包产生一个无效的模块js。
在捆绑上它给了我这个提示。但我找不到任何解决办法。
(!) Missing global variable names
Use output.globals to specify browser global variable names corresponding to external modules
http (guessing 'http')
...
在esm js包中,有如下所示的导入:
import http from 'http';
import h
我遇到这个错误,npm start在执行下面的import时运行得很好: import Header from 'semantic-ui-react/dist/commonjs/elements/Header'; 但是当我做npm测试时,它总是告诉我: ReferenceError: Header is not defined 但是,当我将主文件中的import更改为以下行时,npm测试运行良好 import Header from '../node_modules/semantic-ui-react/dist/commonjs/elements/Header'
我在React组件中使用es2015 Arrow函数,该组件在声明myfunction() {...}时抛出一个错误。如果像这样写myFunction : function () {...},错误就不存在了。我在用Browserify/Babelify编译时没有任何问题--这只发生在下面的示例中。
import React from 'react';
module.exports = React.createClass({
// render : function () { // <--- this works
render() { // <---- t
我已经创建了一个npm库,在那里我正在探索使用汇总进行捆绑。下面是配置:
import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import { terser } from 'rollup-plugin-terser';
import { sizeSnapshot } from 'rollup-plugi
我有一个小的实用程序项目,在那里我使用的是react引导表。我用webpack把这个项目捆绑到不同的项目中。我的webpack配置文件是这样的。当我正在运行的时候,我已经导入了实用程序包的主要项目;我得到了以下错误。
Error: Cannot find module 'jquery' from 'C:\Users\sunny.bogawat\Workspace\Projects\viewpoint_ui_sunny\src\javascript\components\dnsIpam'
at C:\Users\sunny.bogawat\Workspace\Pr