在 web 应用程序中,我已经有一些用“require”声明并被 webpack 理解的包:
- 三
- 三轨控制
这就是我使用它的方式:
var THREE = require('three');
var OrbitControls = require('three-orbit-controls')(THREE);
为了添加物理,我尝试添加库 physijs-webpack:
var PhysiJS = require('physijs-webpack')(THREE);
它在“npm run build”处失败,说:找不到模块:错误:无法解析“physijs-webpack”
在控制台(Chrome 开发工具)中显示以下错误:
"app.js:17 Uncaught Error: Cannot find module "physijs-webpack"
at webpackMissingModule (app.js:17)
at Object.defineProperty.value (app.js:17)
at __webpack_require__ (bootstrap 460ca68f8e6f1e90ea58:19)
at Object.<anonymous> (html5-entities.js:190)
at __webpack_require__ (bootstrap 460ca68f8e6f1e90ea58:19)
at module.exports.ctor.super_ (bootstrap 460ca68f8e6f1e90ea58:62)"
这是我的 webpack.config 文件:
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: './src/js/app.js',
devtool: 'inline-source-map',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/dist'
}
};
依赖项是:
"devDependencies": {
"script-loader": "^0.7.0",
"webpack": "^3.5.4",
"webpack-dev-server": "^2.7.1",
"yarn": "^0.27.5"
},
"dependencies": {
"physijs": "^0.0.4",
"physijs-webpack": "^0.0.2",
"requirejs": "^2.3.4",
"three": "^0.86.0",
"three-orbit-controls": "^82.1.0"
}
}
你能推荐一下吗,我做错了什么?