require js 没有从配置中加载模块

require js is not loading the modules from the configs

我有 index.html 作为:

<!DOCTYPE html>
<html>
    <head>
       <script data-main="scripts/main" src="lib/require.js"></script>
    </head>
    <body>
        <h1>Example 1: basic usage</h1>
    </body>
</html>

main.js:

requirejs.config({
    waitSeconds: 200,
    paths: {
        "app": "app"
    }
});

app.js:

define(function () {
    alert('Hello World');
});

mainapp 都在 scripts 文件夹下。

当我打开 index.html 时,如果我在控制台中输入:

require("app")

我收到这样的错误:

Uncaught Error: Module name "app" has not been loaded yet for context: _. Use require([])

不确定,我哪里弄错了。

您还没有启动您的应用程序,为此您应该调用 requirejs(['app/app'])。 这是基本的 requirejs 示例 https://github.com/volojs/create-template/tree/master/www