我尝试uuid在Node/Typescript应用程序中创建一个(v 3.0.1)包,但我不确定应该导入什么以及如何使用它.
这是index.d.ts(从@types/uuid2.0.29开始):
declare namespace uuid {
interface V1Options {
node?: number[];
clockseq?: number;
msecs?: number | Date;
nsecs?: number;
}
type V4Options = { random: number[] } | { rng: () => number[]; }
interface UuidStatic {
(options?: V4Options): string;
(options: V4Options | null, buffer: number[], offset?: number): number[];
(options: V4Options | null, buffer: Buffer, offset?: number): Buffer;
v1(options?: V1Options): string;
v1(options: V1Options | null, buffer: number[], offset?: number): number[];
v1(options: V1Options | …Run Code Online (Sandbox Code Playgroud) 似乎npm install --prefix ./server(没有参数)不适用于--prefix标志。我只想从 package.json 安装所有包。在该命令之后我得到的只是:
npm WARN enoent ENOENT: 没有这样的文件或目录,打开'/home/.../ProjectName/server/package.json'
当我npm install package_name -S --prefix ./server举个例子时,一切都很好。那么NPM将建立node_modules在server并会增加package_name包。
我的文件结构是:
ProjectName
|
+-- client
| +-- node_modules
| +-- package.json
+-- server
| +-- node_modules
+-- package.json
Run Code Online (Sandbox Code Playgroud)
“Main”package.json包含所有脚本(适用于 Heroku 和适用于我)和服务器的依赖项。
client是 Angular2 应用程序,这就是为什么它有自己的 node_modules 和 package.json。
我使用 NPM 4.2.0。对于 5.0.3 版(最新的?),似乎--prefixflag 根本不起作用。
编辑#1
我刚刚发现我可以用npm install(将安装node_modules在我的项目文件夹中)解决我的问题,然后复制node_modules到server/node_modules. 如果没有该副本,jasmine …
当我MouseEvent在事件处理程序中使用type 时,我无法构建我的React/Typescript应用程序:
private ButtonClickHandler(event: MouseEvent): void
{
...
}
Run Code Online (Sandbox Code Playgroud)
我明白了:
error TS2322: Type '{ onClick: (event: MouseEvent) => void; children: string; }' is not assignable to type 'DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>'.
Type '{ onClick: (event: MouseEvent) => void; children: string; }' is not assignable to type 'ButtonHTMLAttributes<HTMLButtonElement>'.
Types of property 'onClick' are incompatible.
Type '(event: MouseEvent) => void' is not assignable to type 'EventHandler<MouseEvent<HTMLButtonElement>>'.
Types of parameters 'event' and 'event' are incompatible.
Type 'MouseEvent<HTMLButtonElement>' is not assignable to type 'MouseEvent'. …Run Code Online (Sandbox Code Playgroud) 如何os.EOL在Typescript Node.js程序中使用?
import { EOL } from 'os';
console.log("text"+EOL); // ???
Run Code Online (Sandbox Code Playgroud)
这是行不通的。
我下载了os,npm i os -S但文件中node_modules/os/index.js只有一行:module.exports = require('os')。我不明白..
我发现了一些奇怪的事 在角度2组件中,这样的东西不起作用:
<p>
AAA
<ul>
<li>BBB</li>
</ul>
</p>
Run Code Online (Sandbox Code Playgroud)
为什么?(我相信这是有效的HTML)
(如果我</p>在<ul>一切都会好的情况下搬家)
我得到奇怪的错误:
errors.js:64 Uncaught TypeError:无法在assignAll(http://)的SyntaxError.set [as stack](http:// localhost:4200/vendor.bundle.js:66369:61)中设置undefined属性'stack' localhost:4200/vendor.bundle.js:100568:29)在SyntaxError.ZoneAwareError(http:// localhost:4200/vendor.bundle.js:100639:16)处于SyntaxError.BaseError [作为构造函数](http:// localhost:4200/vendor.bundle.js:66331:16)在新的SyntaxError(http:// localhost:4200/vendor.bundle.js:6861:16)处于DirectiveNormalizer.normalizeLoadedTemplate(http:// localhost:4200/vendor) .bundle.js:17962:19)在DirectiveNormalizer.normalizeTemplateSync(HTTP://本地主机:4200/vendor.bundle.js:17939:21)在DirectiveNormalizer.normalizeTemplate(HTTP://本地主机:4200/vendor.bundle.js:17916:43)在CompileMetadataResolver._loadDirectiveMetadata(HTTP:// localhost:4200/vendor.bundle.js:19158:75)位于http:// localhost:4200/vendor.bundle.js:19334:54 位于CompileMetadataResolver.loadNgModuleDirectiveAndPipeMetadata的Array.forEach(native)(http:// localhost: 4200/vendor.bundle.js:19333:41)在http:// localhost:4200/vendor.bundle.js:47800:58 at Array.forEach(native)at JitCompiler._loadModules(http:// localhost:4200/vendor.bundle.js:47799:43)
额外的问题:有没有办法定义此消息中的错误在哪里?