0

I work on a new project, but I can't install packages correctly. I used npm install, yarn, npm install --only=dev, but there aren't enough. I also try like that deleting node_modules and package-lock.json. The state was the same.

We use in the project babel's 6.x version. Babel has a update, 7.x, I think I get the error because of version differences when I run npm install, npm install --only=dev, yarn.

npm WARN deprecated babel-preset-es2015@6.24.1: � Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update! npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN babel-loader@8.0.4 requires a peer of @babel/core@^7.0.0 but none is installed. You must install peer dependencies yourself. npm WARN babel-loader@8.0.4 requires a peer of webpack@>=2 but none is installed. You must install peer dependencies yourself.

I use WebStorm. Before that, I tried to get package for another project with npm install. "Npm" is not successful. WebStorm advice me using Yarn, and I used Yarn. It was worked.

What should I do in the state?

After npm install, when I run parcel index.html, I get the console error

"Uncaught TypeError: window.fooes is not a constructor", Uncaught ReferenceError: regeneratorRuntime is not defined.

I know that the code doesn't have a problem, because project work on the team's computer correctly.

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
yellowpisagor
  • 146
  • 3
  • 13

1 Answers1

0

The first and most important:

Never use npm and yarn at the same time. Choose one of them and use that only because they are both using lock files based on the installed packages.

Which one to use:

npm and yarn are both using the NPM software registry database. So in the end the final result when installing packages are the same, but yarn does the job much-much faster. Yarn was developed by Facebook because the slowness of npm. So I prefer yarn, I'm not using npm commands anymore.

To your problem:

  • Delete the package-lock.json and yarn.lock lock files in your project root directory.
  • Also delete the whole node_modules directory.
  • Now you have only your package.json file. Make a backup of this file!
  • Open the original package.json and I suggest you to first delete all entries from it related to Babel and save it.
  • Now run the yarn command (without params) in the project root (where your package.json file is). This should install all your packages again.

Then install the latest packages of Babel using these commands:

  • yarn add -D @babel/core
  • yarn add -D @babel/preset-env
  • yarn add -D babel-loader

You may need other packages from Babel. Have a look on your backed up package.json and search for the latest versions in the npm registry or Babel's plugins documentation page for the remaining plugins (if any).

szegheo
  • 4,175
  • 4
  • 31
  • 35
  • Thank you. It worked almost. When I install packages of Babel by using command, I see "webpack dependency" so I again install webpack. Webpack get a info **info fsevents@1.2.4: The platform "win32" is incompatible with this module. info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.** I can't solve this. My windows is x64. I can't understand. If I ignore fsevents error, when I try `parcel index.html` I got the same error **Uncaught TypeError: window.fooes is not a constructor** – yellowpisagor Oct 15 '18 at 19:31
  • @yellowpisagor You can safely ignore the `fsevents` warning. I'm on Windows too and I see this warning a lot. It's totally OK, becuase `fsevents` is needed only on Mac OS. Also the warning says it's `optional dependency`. Watching for filesystem changes will just work four you on Windows, no problem. I don't use `parcel` but I think your `window.fooes` error is because of some bug in your `parcel` config file or in some of your own `.js` file. – szegheo Oct 15 '18 at 19:40