简体   繁体   English

参数数量不足或未找到任何条目

[英]Insufficient number of arguments or no entry found

I am building an app which uses client-server comunications and server-google cloud platform comunications by using socket.io.我正在构建一个使用 socket.io 使用客户端-服务器通信和服务器-谷歌云平台通信的应用程序。 For the front-end part I'm using React where I have two components App and Touch.对于前端部分,我使用 React,其中我有两个组件 App 和 Touch。 In the future I'll change project structures but rigth now it looks like this将来我会改变项目结构,但现在看起来像这样

My project structure is the following one:我的项目结构如下:

nodemodulesFolder
publicFolder
  jsFolder
     client.js
     socket.io.js
     socket.io.js
     socket.io.js.map
     touch.js
  viewFolder
     App.js
     index.css
     Touch.js
  index.js
  routes.js
.dockerignore
.env
.gitignore
deployment.yaml
Dockerfile
index.js
ingress.yaml
Jenkinsfike
package.json
package-lock.json
server.js
webpack.config.js

This is my webpack.config.js这是我的 webpack.config.js

'use strict'

module.exports = {
  entry: __dirname + '/cp-test-app/public/index.js',
  output: {
    path: __dirname + '/cp-test-app/public/',
    filename: 'bundle.js'
  },
  module: {
    rules: [
      {
        test: /\.js?$/,
        exclude: /node_modules/,
        loader: 'babel-loader',
        query: {
          presets: ['react', 'es2015']
        }
      },
      { test: /\.css$/,
        use: [
          { loader: "style-loader" },
          { loader: "css-loader" }
        ]
      }
    ]
  },
  resolve: {
    extensions: ['.js', '.jsx']
  }
};

And these are the scripts I'm using to run the app:这些是我用来运行应用程序的脚本:

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "webpack --mode development",
    "build": "webpack --mode production"
}

But somehow I get the following errors:但不知何故,我收到以下错误:

@ start /Users/raulvilloravalencia/OneDrive - Universidad Politécnica de Madrid/Documents/cp-test-app-2/cp-test-app webpack --mode development @ start /Users/raulvilloravalencia/OneDrive - Universidad Politécnica de Madrid/Documents/cp-test-app-2/cp-test-app webpack --mode development

Insufficient number of arguments or no entry found.
Alternatively, run 'webpack(-cli) --help' for usage info.

Hash: 14907618cdf8c7e77e94
Version: webpack 4.20.2
Time: 66ms
Built at: 2018-09-28 10:41:38

ERROR in Entry module not found: Error: Can't resolve '/Users/raulvilloravalencia/OneDrive - Universidad Politécnica de Madrid/Documents/cp-test-app-2/cp-test-app/cp-test-app/public/index.js' in '/Users/raulvilloravalencia/OneDrive - Universidad Politécnica de Madrid/Documents/cp-test-app-2/cp-test-app'
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ start: `webpack --mode development`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @ start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/raulvilloravalencia/.npm/_logs/2018-09-28T08_41_39_055Z-debug.log

My package.json looks like this :我的 package.json 看起来像这样:

{
  "description": "Google Cloud Speech Playground with node.js and socket.io.",
  "main": "server.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "webpack --mode development",
    "build": "webpack --mode production"
  },
  "author": "",
  "license": "ISC",
  "babel": {
    "presets": [
      "env",
      "react"
    ],
    "plugins": [
      "transform-object-rest-spread"
    ]
  },
  "dependencies": {
    "@google-cloud/speech": "1.5.0",
    "@grpc/proto-loader": "^0.3.0",
    "@webpack-cli/init": "^0.1.1",
    "ajv": "^6.5.4",
    "ajv-keywords": "^3.2.0",
    "babel-preset-es2015": "^6.3.13",
    "babel-preset-react": "^6.3.13",
    "babel-register": "^6.3.13",
    "cors": "^2.8.4",
    "dotenv": "^4.0.0",
    "ejs": "^2.5.7",
    "express": "^4.16.3",
    "isomorphic-fetch": "^2.2.1",
    "json-loader": "^0.5.4",
    "nodemon": "^1.18.4",
    "path": "^0.12.7",
    "react": "^16.5.2",
    "react-dom": "^16.5.2",
    "react-engine": "^4.5.1",
    "react-router": "^3.2.1",
    "react-router-dom": "^4.2.2",
    "serialize-javascript": "^1.4.0",
    "serve-favicon": "^2.3.0",
    "socket.io": "^2.0.4"
  },
  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.5",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "babel-preset-env": "^1.7.0",
    "css-loader": "^1.0.0",
    "extract-text-webpack-plugin": "^3.0.2",
    "nodemon": "^1.9.2",
    "webpack": "^4.20.2",
    "webpack-cli": "^3.1.1",
    "webpack-node-externals": "^1.6.0"
  }
}

Webpack is looking for /cp-test-app-2/cp-test-app/cp-test-app/public/index.js , while it should be looking for /cp-test-app-2/cp-test-app/public/index.js . Webpack 正在寻找/cp-test-app-2/cp-test-app/cp-test-app/public/index.js ,而它应该寻找/cp-test-app-2/cp-test-app/public/index.js

Specify the correct relative paths in your webpack.config.js by removing the extra /cp-test-app :通过删除额外的/cp-test-appwebpack.config.js指定正确的相对路径:

'use strict'

module.exports = {
  entry: __dirname + '/public/index.js',
  output: {
    path: __dirname + '/public/',
    filename: 'bundle.js'
  },
  module: {
    rules: [
      {
        test: /\.js?$/,
        exclude: /node_modules/,
        loader: 'babel-loader',
        query: {
          presets: ['react', 'es2015']
        }
      },
      { test: /\.css$/,
        use: [
          { loader: "style-loader" },
          { loader: "css-loader" }
        ]
      }
    ]
  },
  resolve: {
    extensions: ['.js', '.jsx']
  }
};

Probably irrelevant to this particular error, but you need to use the following syntax to specify the mode:可能与此特定错误无关,但您需要使用以下语法来指定模式:

webpack --mode=development
//            ^      
// Notice the equals sign.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM