I use node, react and requirejs (and create my JM-compatible JS from Typescript, but I don't think this is relevant to the problem). I am just trying to require React in my application:
require.config({
baseUrl: '../scripts/lib/node_modules',
paths: {
lib: '..',
react: 'react/lib',
app: '../../app',
jquery: 'jquery/dist/jquery',
scripts: '../..',
},
});
require(['react/React'], function (react) {
});
Then I will load this configuration using the RequireJS data-mainapi by going to this page:
<!DOCTYPE html>
<html>
<head>
<title>My Updated Test Project</title>
<script data-main="../scripts/config.js" src="../scripts/lib/node_modules/requirejs/require.js"></script>
</head>
<body>
<h1>My Test Project</h1>
</body>
</html>
RequireJS complains when trying to download React:
Error: Module name "EventPluginUtils" has not been loaded yet for context: _. Use require([])
In React.js, almost the first line is "bare required"
var EventPluginUtils = require("./EventPluginUtils");
If I read RequireJS information about this error message, it says that the fix is to stop using bare require.
, require ('name'), 'name' . Use require ([]), ( define()), ,
, AMD , React. ? , React.js require ? . - RequireJS? ( ).
Edit:
React CommonJS, : RequireJS : http://requirejs.org/docs/api.html#packages.
, React package.json, , . baseUrl, , .