Npm Err! Code Elifecycle Npm Err! Errno 2

Npm Err! Code Elifecycle Npm Err! Errno 2

I am getting this error when I'm try to run - npm run dev in my command prompt:

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

Hash: af4cfdb00272137cb4d3
Version: webpack 4.41.5
Time: 60ms
Built at: 02/05/2020 10:38:54 AM

WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: 

ERROR in Entry module not found: Error: Can't resolve './src' in 'C:\Users\dahiy\Desktop\Web developer Course\JS - Basics 2\forkit'
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! forkify@1.0.0 dev: `webpack`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the forkify@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

This is how my webpack.config.js looks like:

const path = require('path');

module.exports = {
    entry:'./src/js/index.js',
    output: {
        path: path.resolve(__dirname, 'dist/js'),
        filename:'bundle.js'
    }, 
    mode:'development'  
};

This is my package.json:

{
  "name": "forkify",
  "version": "1.0.0",
  "description": "forkify project",
  "main": "index.js",
  "scripts": {
    "dev": "webpack"
  },
  "author": "Sachin Dahiya",
  "license": "ISC",
  "devDependencies": {
    "webpack": "^4.41.5",
    "webpack-cli": "^3.3.10"
  },
  "dependencies": {}
}

I have tried everything to solve this error but not getting any solution to resolve this. Please help me out. Attaching the screenshot of the error here. error

2

2 Answers

// webpack.config.js

const path = require('path');

module.exports = {
    entry: path.resolve(__dirname, 'src/js/index.js'),
    output: {
        path: path.resolve(__dirname, 'dist/js'),
        filename:'bundle.js'
    }, 
    mode:'development'  
};

since you're on Windows, looks like the forward/backward slash confusion is the issue

2

Check the name of the file for CAPS. Running on the local machine was not giving error but when I was running on linux, it was giving me a similar error as above.

I found the issue with name of the file. While doing import I had

import Login from "./login";

But name of the file was Login.js When I changed login to Login, it worked for me import Login from "./Login";

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins
Author

Sarah Jenkins

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.