在使用grunt时使用browserify和babel时遇到一个奇怪的问题。在Mac和Windows计算机的生成代码中,一切工作正常,但是某些Windows计算机在生成的代码中存在问题,并且未找到模块,浏览器中出现错误。
_prelude.js:1 Uncaught Error: Cannot find module './<module-name>'
at o (_prelude.js:1)
at _prelude.js:1
at Object.5.././<module-name> source-file.js:1)
at o (_prelude.js:1)
at r (_prelude.js:1)
at _prelude.js:1
艰巨的任务:
browserify: {
dist: {
files: {
'desktop/common/js/src/js-compiled/script-generated.js': [
'desktop/common/js/src/source-file1.js','desktop/common/js/src/source-file2.js','desktop/common/js/src/source-file3.js',]
},options: {
transform: [
['babelify',{
presets: "es2015"
}]
],browserifyOptions: {
debug: true
}
}
}
},
打包JSON:
"@babel/core": "^7.6.2","babel-cli": "^6.26.0","babel-polyfill": "^6.26.0","babel-preset-es2015": "^6.24.1","babelify": "7.2.0 ","grunt": "~0.4.2","grunt-browserify": "^5.3.0",