npm configuration.output.path:提供的值.“/”不是绝对路径

gojuced7  于 2022-11-14  发布在  其他
关注(0)|答案(2)|浏览(138)

出现错误:配置对象无效。已使用与API架构不匹配的配置对象初始化Webpack。- configuration.output.path:提供的值“./”不是绝对路径!
在安装reactjs时我的package.json文件在下面

{
  "name": "reactset",
  "version": "1.0.0",
  "description": "react",
  "main": "index.js",
  "scripts": {
    "start": "webpack-dev-server --hot"
  },
  "keywords": [
    "test"
  ],
  "author": "test",
  "license": "ISC",
  "dependencies": {
    "babel-core": "^6.25.0",
    "babel-loader": "^7.1.1",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "react": "^15.6.1",
    "react-dom": "^15.6.1",
    "webpack": "^3.0.0",
    "webpack-dev-server": "^2.5.0"
  }
}
using upgraded node version 4.0 and npm 5.0 
Error : 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactset@1.0.0 start: `webpack-dev-server --hot`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the reactset@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

请帮忙解答解答:用于安装的帮助URL:
https://www.tutorialspoint.com/reactjs/reactjs_environment_setup.htm

3gtaxfhh

3gtaxfhh1#

请更改

output: {
      path:'./',
      filename: 'index.js',
   }

结束日期

output: {
      path: __dirname+'/',
      filename: 'index.js',
   }

或者换句话说,更改path: __dirname + '/'

7nbnzgx9

7nbnzgx92#

如果您使用ES模块,请使用以下命令:

output: {
  path: process.cwd(),
  filename: 'index.js',
}

output: {
  path: path.join(process.cwd(), 'dist'),
  filename: 'index.js',
}

相关问题