Ubuntu 16.04中的ReactJS设置出错

时间:2017-08-15 08:06:39

标签: node.js reactjs ubuntu-16.04

我尝试关注https://www.tutorialspoint.com/reactjs/reactjs_environment_setup.htm以便在我的设备中设置具有Ubuntu 16.04的reactJS。

最后我尝试了npm start但是它导致我跟踪错误

> reactjs@1.0.0 start /var/www/html/reactjs
> webpack-dev-server --hot

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.output.path: The provided value "./" is not an absolute path!

npm ERR! Linux 4.10.0-28-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! reactjs@1.0.0 start: `webpack-dev-server --hot`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the reactjs@1.0.0 start script 'webpack-dev-server --hot'.
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 reactjs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     webpack-dev-server --hot
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs reactjs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls reactjs
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/html/reactjs/npm-debug.log

我的 package.json 文件

{
  "name": "reactjs",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "webpack-dev-server --hot"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "react": "^15.6.1",
    "webpack": "^3.5.4",
    "webpack-dev-server": "^2.7.1"
  }
}

2 个答案:

答案 0 :(得分:1)

有史以来最直接的错误消息。

你不能在输出中使用相对路径(我不记得以前版本的webpack中是否可以)。 Docs

output: {
   path: require('path').resolve(__dirname, './path/to/build/folder'),

答案 1 :(得分:0)

使用 create-react-app 创建新的reactjs应用程序。

只需删除node_modules文件夹,然后使用npm install重新安装npm包。