我试图学习现代Javascript,但遇到了一些问题。早些时候我在similar, possibly related issue收到了很好的帮助,我担心我会再次陷入困境。
我尝试使用Webpack作为构建系统在TypeScript中编写NodeJS应用程序。我尝试使用Puppeteer来自动化网络上的一些东西,但是在尝试包含该模块时,Webpack扼杀了:
[ger@rd] 21:53 $ npm run build
> startpage@1.0.0 build /home/ger/projects/startpage
> webpack
Hash: 1372c5ea796906ef9a87
Version: webpack 3.11.0
Child
Hash: 1372c5ea796906ef9a87
Time: 1611ms
Asset Size Chunks Chunk Names
run_task.js 932 kB 0 [emitted] [big] main
[46] ./node_modules/puppeteer/lib 160 bytes {0} [built]
[60] ./node_modules/puppeteer/node6/lib 160 bytes {0} [built]
[63] ./src/run_task.ts 341 bytes {0} [built]
[64] ./src/Badoo.ts 1.62 kB {0} [built]
+ 131 hidden modules
WARNING in ./node_modules/puppeteer/lib/BrowserFetcher.js
251:18-33 Critical dependency: the request of a dependency is an expression
@ ./node_modules/puppeteer/lib/BrowserFetcher.js
@ ./node_modules/puppeteer/lib/Puppeteer.js
@ ./node_modules/puppeteer/index.js
@ ./src/Badoo.ts
@ ./src/run_task.ts
WARNING in ./node_modules/puppeteer/lib/Launcher.js
26:25-81 Critical dependency: the request of a dependency is an expression
@ ./node_modules/puppeteer/lib/Launcher.js
@ ./node_modules/puppeteer/lib/Puppeteer.js
@ ./node_modules/puppeteer/index.js
@ ./src/Badoo.ts
@ ./src/run_task.ts
WARNING in ./node_modules/puppeteer/node6/lib/Launcher.js
26:25-81 Critical dependency: the request of a dependency is an expression
@ ./node_modules/puppeteer/node6/lib/Launcher.js
@ ./node_modules/puppeteer/node6/lib/Puppeteer.js
@ ./node_modules/puppeteer/index.js
@ ./src/Badoo.ts
@ ./src/run_task.ts
WARNING in ./node_modules/puppeteer/node6/lib/BrowserFetcher.js
329:18-33 Critical dependency: the request of a dependency is an expression
@ ./node_modules/puppeteer/node6/lib/BrowserFetcher.js
@ ./node_modules/puppeteer/node6/lib/Puppeteer.js
@ ./node_modules/puppeteer/index.js
@ ./src/Badoo.ts
@ ./src/run_task.ts
WARNING in ./node_modules/ws/lib/BufferUtil.js
Module not found: Error: Can't resolve 'bufferutil' in '/home/ger/projects/startpage/node_modules/ws/lib'
@ ./node_modules/ws/lib/BufferUtil.js 35:21-42
@ ./node_modules/ws/lib/Receiver.js
@ ./node_modules/ws/index.js
@ ./node_modules/puppeteer/lib/Connection.js
@ ./node_modules/puppeteer/lib/Launcher.js
@ ./node_modules/puppeteer/lib/Puppeteer.js
@ ./node_modules/puppeteer/index.js
@ ./src/Badoo.ts
@ ./src/run_task.ts
WARNING in ./node_modules/ws/lib/Validation.js
Module not found: Error: Can't resolve 'utf-8-validate' in '/home/ger/projects/startpage/node_modules/ws/lib'
@ ./node_modules/ws/lib/Validation.js 10:22-47
@ ./node_modules/ws/lib/Receiver.js
@ ./node_modules/ws/index.js
@ ./node_modules/puppeteer/lib/Connection.js
@ ./node_modules/puppeteer/lib/Launcher.js
@ ./node_modules/puppeteer/lib/Puppeteer.js
@ ./node_modules/puppeteer/index.js
@ ./src/Badoo.ts
@ ./src/run_task.ts
我的webpack.config.js
:
const path = require('path');
module.exports = [
{
// devtool: 'inline-source-map',
entry: './src/run_task.ts',
target: 'node',
module: {
rules: [
{
test: /\.tsx?$/,
use: [
{
loader: 'ts-loader',
options: { configFile: 'server.tsconfig.json' }
}
],
exclude: /node_modules/
}
]
},
resolve: {
extensions: [ '.ts', '.tsx', '.js' ]
},
output: {
filename: 'run_task.js',
path: path.resolve(__dirname, 'dist')
}
}
];
我的package.json
:
{
"name": "startpage",
"version": "1.0.0",
"description": "Self hosted web app to function as a web browser startpage",
"main": "run_task.js",
"scripts": {
"build": "webpack",
"start": "node dist/run_task.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Gerard Leenhouts",
"license": "ISC",
"devDependencies": {
"@types/node": "^9.4.6",
"@types/puppeteer": "^1.0.0",
"ts-loader": "^3.5.0",
"typescript": "^2.7.2",
"webpack": "^3.11.0"
},
"dependencies": {
"puppeteer": "^1.1.0"
}
}
我的server.tsconfig.json
:
{
"compilerOptions": {
// "sourceMap": true,
"outDir": "./dist/",
"strict": true,
"noImplicitAny": true,
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
// "baseUrl": "./",
// "paths": { "*": ["node_modules/*", "src/types/*"] },
"removeComments": true
},
"include": [ "./src/**/*" ]
}
我不知道出了什么问题,任何人都可以填写我的信息吗?