Typescript写爬虫
检验代码是否成功
项目打包
"scripts": {
"dev": "ts-node ./src/crowller.ts",
"build":"tsc"
},
npm run build
这时候就会把ts文件编译成js文件
然后打包,在tsconfig.json
找到 “outDir”: “./build”, 把注释去掉就可以了,然后就会产生打包文件夹build
...
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./build", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": ".
...