1

I' am currently working in React, and I'm trying to setup webpack and webpack-cli. I am currently following the tutorial on webpack 4 tutorial site https://www.valentinog.com/blog/webpack-4-tutorial/ using my command line I've been trying to install webpack and webpack-cli as my dependencies using nodejs.

I've been entering npm i webpack --save-dev and npm i webpack-cli --save-dev Both these modules install correctly and are added to my package.json as dependencies.

 {
  "name": "webpack-4-quickstart",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "webpack"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "webpack": "^4.10.1",
    "webpack-cli": "^2.1.4"
  }
}

I also have a scripts section that has a "build": "webpack" which should initialize my webpack. But when I type npm run build i get this error. Error: Cannot find module '@webassemblyjs/ast'. I've checked my node_modules and @webassemblyjs is there.

I've tried uninstalling my node_modules, reinstalling webpack and webpack-cli and even moved to a different directory and repository to see if I could change my outcome that way. However, I'm still getting this cannot find module @webassemblyjs/ast. I'm currently running MacOs High Sierra, and am not sure if maybe it's just not agreeing with my operating system. If anything I haven't noticed any other Stackoverflow posts dealing with this specific error, so I thought I'd make a post asking for help.

Thankyou for your time!

3 Answers 3

5

I had the same problem. After trying many variations of version, deleting node modules a couple times, trying to manually install the library, I finally solved it by running

npm ci

~1 day hours of debugging, 6 letter command. Computers are so fun sometimes

Sign up to request clarification or add additional context in comments.

Comments

0

try this

update "webpack": "^4.10.1" to "webpack": "^3.11.0"

1 Comment

Thankyou! I've just installed webpack version 3.11.0. I think I'll need to create a config file when using this version. But so far I don't have that error using 3 instead of 4.
0

No issues on macOS High Sierra with:

"devDependencies": {
    "webpack": "^4.12.0",
    "webpack-cli": "^3.0.8"
}

Try first upgrading to those versions and see if that resolves the issue.

Also, are you using a private registry? If so, you might be getting something like this if @webassemblyjs can't be found in it:

npm ERR! code E404
npm ERR! 404 Not Found: @webassemblyjs/[email protected]

You could quickly fix this by adding @webassemblyjs:registry=https://registry.npmjs.org in your .npmrc file.

Otherwise, you could try running webpack --display-error-detail and see if you get additional details about the error.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.