我尝试使用Browserify将一些JS文件打包在一起以便传递给客户端。我使用npm install --save-dev browserify
来安装软件包。它给了我错误:
Cannot find module 'source-map'
我通过Node.js项目中的package.json脚本运行Browserify。
// package.json
{
// ...
"scripts": {
// ...
"cyoagify": "browserify entry.js -o public/js/cyoag.js"
},
"dependencies": {
"body-parser": "~1.15.1",
"cookie-parser": "~1.4.3",
"debug": "~2.2.0",
"express": "~4.13.4",
"handlebars": "^4.0.5",
"jade": "~1.11.0",
"morgan": "~1.7.0",
"serve-favicon": "~2.3.0"
},
"devDependencies": {
"browserify": "^13.1.0"
}
}
命令行执行:
npm run cyoagify
我也尝试过:
browserify entry.js -o public/js/cyoagify.js
没有骰子。对于它的价值,这里是entry.js
:
// external libraries
require('./js/jquery');
var Handlebars = require('./js/handlebars-v4.0.5');
// precompiled HBS loaders
require('./js/hbs-ified/authoring');
require('./js/hbs-ified/body');
require('./js/hbs-ified/header');
require('./js/hbs-ified/lastPathSnippet');
require('./js/hbs-ified/nodeSnippet');
require('./js/hbs-ified/trailingSnippet');
require('./js/hbs-ified/votification');
require('./js/hbs-ified/votifiedPaths');
// internal libraries
var Builders = require('./js/builders')(Handlebars);
请帮忙!
编辑:我手动执行了npm install -g source-map
并安装了它,但这没有帮助。
更新:source-map
似乎被Handlebars中的语句require('source-map')
引用。但为什么不能找到它?