我需要为我的代码创建一个 Hammer 的别名。我在 tsconfig 中添加了路径,如下所示:
{
"compilerOptions": {
"declaration": true,
"noImplicitAny": false ,
"noEmitOnError": true,
"noUnusedLocals": false ,
"noUnusedParameters": false ,
"module": "commonjs",
"moduleResolution": "node",
"target": "ES5",
"outDir": "./lib",
"lib": ["ES5", "ES2015.Promise", "DOM", "ES2015.Collection", "es2016"],
"jsx": "react",
"types": [],
"baseUrl": ".",
"paths": {
"Hammer": ["hammerjs/hammer.js"]
}
},
"include": ["typings/index.d.ts","src/*"]
}
但是在geo.js中我仍然遇到错误,我有'require(Hammer)'。我错过了什么?
ERROR in ./~/geojs/geo.js
Module not found: Error: Can't resolve 'Hammer' in '/home/chaudhary/tools/jupyterlab/mydev/share/jupyter/lab/staging/node_modules/geojs'
@ ./~/geojs/geo.js 3:27-44
@ ./~/@jupyterlab/geojson-extension/lib/index.js
@ ./build/index.out.js