如上所述,尝试运行 facebook Flux 应用程序 here 。我有以下 js 应用程序的树结构
│ .bundle.js
│ app.jsx
│ bundle.js
│
├───actions
│ TodoActions.jsx
│
├───components
│ Footer.jsx
│ Header.jsx
│ MainSection.jsx
│ TodoApp.jsx
│ TodoItem.jsx
│ TodoTextInput.jsx
│
├───constants
│ TodoConstants.jsx
│
├───dispatcher
│ AppDispatcher.jsx
│ Dispatcher.jsx
│
└───store
TodoStore.jsx
在app.jsx中代码就像
var React = require('react');
var TodoApp = require('./components/TodoApp');
React.render(
<TodoApp />,
document.getElementById('todoapp')
);
在 TodoApp.jsx 中,我将模块导出为
module.exports = TodoApp;
当我尝试制作 build.js 时,它出现错误,如下所示
Error: Cannot find module './components/TodoApp' from 'c:\www\example\react\flux\js'
不知道我哪里错了?如果我需要提供任何进一步的信息,请告诉我
最佳答案
经过谷歌搜索一段时间后,我得到了解决方案。实际问题是 require
查找 js
扩展名,但我有带有 jsx
的文件。
得到我的解决方案here
关于node.js - 在 npm 中找不到模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28655597/