反应教程后无法启动节点

时间:2017-07-06 14:50:44

标签: javascript node.js reactjs

我正在关注这个反应教程,但我担心它可能有点过时,因为它是在几年前编写的。所以在创建文件并安装一些软件包之后,我尝试通过启动来运行应用程序节点,我收到此错误消息。

C:\Users\George\Desktop\reactapp>npm start

> reactapp@1.0.0 start C:\Users\George\Desktop\reactapp
> node server.js

module.js:471
    throw err;
    ^

Error: Cannot find module 'C:\Users\George\Desktop\reactapp\server.js'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:389:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:504:3

npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\\nodejs\\node.exe" "C:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.11.0
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! reactapp@1.0.0 start: `node server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactapp@1.0.0 start script 'node server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the reactapp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs reactapp
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls reactapp
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\George\Desktop\reactapp\npm-debug.log

C:\Users\George\Desktop\reactapp>

1 个答案:

答案 0 :(得分:0)

我会放弃它教给您的第一种方法,因为它的传承并为您省去了挫败感,因为作者并不清楚他要安装的reactreact-dom版本,因此您必须查看该博客文章的日期,然后研究一下当时的最新版本是什么版本。然后是Webpack来处理,因此对于那些未维护的tutorialspoint.com Reactjs教程的所有未来用户,只需遵循CRA步骤并忽略构建React应用程序的旧方法,特别是如果您不熟悉Reactjs。

如果由于某种原因而想尝试传统方法,因为您想弄脏Webpack,可以随时在创建的CRA应用程序上执行npm run eject,然后离开,使用Webpack和Babel。