如何编译和运行附加的反应Web应用程序?

时间:2016-12-01 09:18:17

标签: node.js reactjs npm webpack package.json

我是node和npm的新手。我一直在尝试编译我在GitHub上找到的这个Medication提醒应用程序(https://github.com/marshallmurphy/Web-Apps/tree/master/Medication%20Reminder%20React%20App),但是npm一直产生错误。我试过“npm start”并运行“webpack”但没有运气。如何在终端中编译和运行此文件?

运行npm start时出现以下错误:

Dantes-MBP:Medication Reminder React App dantegreyson$ npm start

> medication-reminder-app@1.0.0 start /Users/dantegreyson/Desktop/Medication Reminder React App
> webpack-dev-server

sh: webpack-dev-server: command not found

npm ERR! Darwin 16.1.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.9.1
npm ERR! npm  v4.0.2
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! medication-reminder-app@1.0.0 start: `webpack-dev-server`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the medication-reminder-app@1.0.0 start script 'webpack-dev-server'.
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 medication-reminder-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     webpack-dev-server
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs medication-reminder-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls medication-reminder-app
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/dantegreyson/Desktop/Medication Reminder React App/npm-debug.log

我尝试按照建议全局安装webpack,但现在收到以下错误:

Dantes-MBP:Medication Reminder React App dantegreyson$ npm start

> medication-reminder-app@1.0.0 start /Users/dantegreyson/Desktop/Medication Reminder React App
> webpack-dev-server

module.js:471
    throw err;
    ^

Error: Cannot find module 'html-webpack-plugin'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/dantegreyson/Desktop/Medication Reminder React App/webpack.config.js:1:87)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

npm ERR! Darwin 16.1.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.9.1
npm ERR! npm  v4.0.2
npm ERR! code ELIFECYCLE
npm ERR! medication-reminder-app@1.0.0 start: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the medication-reminder-app@1.0.0 start script 'webpack-dev-server'.
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 medication-reminder-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     webpack-dev-server
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs medication-reminder-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls medication-reminder-app
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/dantegreyson/Desktop/Medication Reminder React App/npm-debug.log

1 个答案:

答案 0 :(得分:2)

如果您在脚本部分查看 package.json ,您将看到它尝试运行的内容 "start": "webpack-dev-server"。因此,您应该全局安装webpack-dev-server sudo npm install webpack-dev-server -g应该为你做所有的魔法。

更新

确保您运行npm install命令