'Cannot find module 'webpack' - BigCommerce

Needing to run a BigCommerce site locally and not sure why it's not running. It's running an older version of Cornerstone (V4.4.0) so not sure how to fix:

Node Version: V12.22.7

NPM: 6.14.15

Stencil version - 3.7.0

Error:

Error: Cannot find module 'webpack'
Require stack:

  • /path-to-directory/stencil.conf.js

  • /.nvm/versions/node/v12.22.7/lib/node_modules/@bigcommerce/stencil-cli/lib/BuildConfigManager.js

  • /.nvm/versions/node/v12.22.7/lib/node_modules/@bigcommerce/stencil-cli/lib/stencil-start/js

  • /.nvm/versions/node/v12.22.7/lib/node_modules/@bigcommerce/stencil-cli/bin/stencil-start.js

at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
at Function.Module._load (internal/modules/cjs/loader.js:667:27)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helps.js:74:18)
at Object. (path-to-directory/stencil.conf.js:1:15)

As well as this:

npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t git://github.com/bigcommerce-labs/node-sass.git
npm ERR!
npm ERR! fatal: remote error:
npm ERR! The unauthenticated git protocol on port 9418 is no longer supported.
npm ERR! Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.
npm ERR!
npm ERR! exited with error code: 128

I have tried moving back Node version but error persists. Checked API key incase it needed to be updated and not the issue.



Solution 1:[1]

Check if you have any dependency in your package.json pointing to git://github.com url. Those are now deprecated, you must use https, e.g. git+https://github.com/bigcommerce-labs/node-sass.git.

Solution 2:[2]

I ran into this same exact issue yesterday and I believe the answer has to do with recent update to security protocols outlined in the link that pops up in the errors in your console after running npm i. What I think has happened is your remote git user setup is prepended with git://, which is no longer valid and must be prepended with https:// instead. If you run the following command in your terminal, it should adjust all of your repositories globally and you should no longer have an issue:

git config --global url."https://".insteadOf git://

Now, try running npm i again and you should be good to go. I found this solution while looking to solve this same issue at https://github.com/heroku/heroku-buildpack-nodejs/issues/959

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Istvan Tabanyi
Solution 2 Keith McGowan