Keep getting stuck while setting up npm on windows

Viewed 225

I am currently working my way through a course on UDEMY and we're setting up nodejs and npm. I have started over from scratch 4 times now and I keep getting stuck at the same point. I will try and explain to the best of my abilities but I'm still learning so I hope I can convey my problem coherently.

I have nodejs v10.21.0 and npm v6.14.5. I type into the terminal sudo npm init. I type in all the necessary things and I end up with a package.json file. Then we install webpack. I enter into the terminal sudo npm install webpack --save-dev. The webpack shows up in the devDependencies just like it should. We also get a file named package-lock.json as well as the node_modules folder. Everything up to this point works just as described in the lecture. We then create a new webpack.config.js file and enter in

const path = require('path');

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

We create a new file named test.js with the following code:

console.log('Imported Module');

export default 23;

And enter this code into our index.js file:

import num from './test';

console.log(`I imported ${num} from another module!`);

We then go back to the package.json file and change the scripts in order to run the script we want. Our package.json file looks like this:

{
  "name": "forkify",
  "version": "1.0.0",
  "description": "forkify project",
  "main": "index.js",
  "scripts": {
    "dev": "webpack"
  },
  "author": "cwelonlonranch",
  "license": "ISC",
  "devDependencies": {
    "webpack": "^4.43.0"
  }
}

Here is where things just stop working. We want to add webpack-cli to the package.json file so in the terminal we enter sudo npm install --save-dev webpack-cli@2. This is how the instructor asked us to enter it but I have tried both with and without the @2 on fresh attempts to no avail. When I installed webpack the package.json file updated on its own just fine but somewhere between then and here it for some reason will not update when installing the webpack-cli feature. Can anyone give me any insight as to what is wrong and what breaks my files between when they're working and when they stop working?

Here are the warnings I'm getting when I run sudo npm install --save-dev webpack-cli:

npm WARN deprecated nomnom@1.8.1: Package no longer supported. Contact support@npmjs.com for more info.
npm WARN deprecated babel-preset-es2015@6.24.1:   Thanks for using Babel: we recommend using babel-preset-env now: please read https://babeljs.io/env to update!
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN forkify@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

0 Answers
Related