简体   繁体   English

AngularJs DateTimepicker-尝试在Pug模板中包含.js.map文件时出错

[英]AngularJs DateTimepicker - error when trying to include .js.map file in pug template

I am running a MEAN stack environment, and ran into an issue when trying to include a third party addon to angularjs material. 我正在运行MEAN堆栈环境,并且在尝试将第三方插件包含到angularjs材料中时遇到问题。

We have a PUG template acting as our main view, and are declaring all dependencies there. 我们有一个PUG模板作为我们的主视图,并在那里声明所有依赖项。 In it, I have this line: 在其中,我有这行:

script(type="text/javascript" src="scripts/ng-material-datetimepicker/dist/angular-material-datetimepicker.min.js")
script(type="text/javascript" src="scripts/ng-material-datetimepicker/dist/angular-material-datetimepicker.min.js.map")
link(rel="stylesheet" href="scripts/ng-material-datetimepicker/dist/material-datetimepicker.min.css")

the scripts portion of the src is set to our node-modules folder using this line: 使用此行将src的scripts部分设置为我们的node-modules文件夹:

app.use('/scripts', express.static(path.join(__dirname, ".\\node_modules")));

With that setup, I am getting the following error in the dev console, in reference to the .map.js file only (everything else seems to work): 通过该设置,我仅在参考.map.js文件的情况下在开发控制台中遇到以下错误(似乎其他所有方法都可行):

Uncaught SyntaxError: Unexpected token :

I have seen some answers regarding the MIME type being incorrect, or this being an issue with chrome, but I'm starting to lean towards something of mine being set up incorrectly. 我已经看到一些有关MIME类型不正确的答案,或者这是chrome的问题,但是我开始倾向于我的设置不正确。 What am I doing wrong? 我究竟做错了什么?

With the help of the author, i have this figured out. 在作者的帮助下,我已经弄清楚了。 In this specific case, the .js.map file was not needed. 在此特定情况下,不需要.js.map文件。 Also changed the below lines a bit (removed the type attribute for the js file, and used non-minified versions): 还稍微更改了以下几行(删除了js文件的type属性,并使用了非缩小版本):

script(src="scripts/ng-material-datetimepicker/js/angular-material-datetimepicker.js")
link(rel="stylesheet" type="text/css" href="scripts/ng-material-datetimepicker/css/material-datetimepicker.css")

Here is a link to the github exchange with the author. 是与作者进行github交换的链接。 Hopefully this answer helps a random browser in the future :) 希望这个答案将来对随机浏览器有所帮助:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM