简体   繁体   English

无法加载require.js主模块

[英]can not load require.js main module

I'm trying to use require.js in my app but it looks like it doesnt see the path of the main. 我正在尝试在我的应用程序中使用require.js,但它似乎看不到main的路径。

There is script for loading: 有用于加载的脚本:

<script data-main='public/scripts/main.js' src='public/scripts/require.js'></script>

i tried everything /public/scripts/main.js, public/scripts/main and others but im still getting: 我尝试了/public/scripts/main.js、public/scripts/main和其他所有内容,但即时通讯仍在获取:

Uncaught SyntaxError: Unexpected identifier
at exec (require.js:2410)
at XMLHttpRequest.xhr.onreadystatechange (require.js:2421)

I think the problem is in the node middleware path, when I'm trying to load it with just index.html and scripts it works, but with whole backend stuff it doesn't :( 我认为问题出在节点中间件路径中,当我尝试仅使用index.html和脚本加载它时,它可以工作,但是对于整个后端,它不是:(

There is how I set /public in node: 我是如何在节点中设置/ public的:

  Server.app.use('/public', express.static(path.join(__dirname, 'public')));

Any one know the solution? 有人知道解决方案吗?

您可以重试:

<script data-main='/public/scripts/main.js' src='/public/scripts/require.js'></script>

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

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