So, I've seen other similar issues. There are a lot, but I can't seem to find a solution for this.
I've already deleted node_modules folder and package-lock.json file from /{username} , where my package.json file is. However, every time I install something globally, it does not update the package.json file, but does install it in /usr/local/lib/node_modules.
This happens every time I run ncu.
Any ideas?
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module '../../package.json'
Require stack:
- /usr/local/lib/node_modules/npm-check-updates/build/src/bin/cli.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/usr/local/lib/node_modules/npm-check-updates/build/src/bin/cli.js:11:40)
at Module._compile (node:internal/modules/cjs/loader:1095:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1147:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/local/lib/node_modules/npm-check-updates/build/src/bin/cli.js'
]
}
Node.js v17.0.1
I have just experienced the same. I think it's a bug in the latest version of NCU (12.0.1, released 5 hours ago at the time of writing).
If I run
npm install npm-check-updates#12.0.0 -g
then ncu runs fine.
If I run
npm install npm-check-updates#12.0.1 -g
then it barfs with this error.
I just checked the Github page and found that the issue has already been raised as https://github.com/raineorshine/npm-check-updates/issues/990.
So I guess, follow that issue for any other workarounds and the eventual fix.
I solved this to removing the node_modules folder, package-lock.json file and executing:
npm install
I've been scratching my head over this for an hour and the answer by #Alberto Manuel helped me find the solution. I, too, cleared the node_modules, package-lock.json and tried npm install but that didn't work.
Then I did npm install --legacy-peer-deps after clearing both the node_modules, package-lock.json. That finally fixed my issue.
Looks like npm install was overriding the legacy versions of dependencies with higher versions or skipping them altogether.
Related
I'm running into an issue while trying to install the Solidity compiler locally through npm. After running npm i -g solc and checking for installation by running any commands such as solcjs --help, I receive the following error:
internal/modules/cjs/loader.js:905
throw err;
^
Error: Cannot find module './common/helpers'
Require stack:
- /usr/local/lib/node_modules/solc/linker.js
- /usr/local/lib/node_modules/solc/translate.js
- /usr/local/lib/node_modules/solc/wrapper.js
- /usr/local/lib/node_modules/solc/index.js
- /usr/local/lib/node_modules/solc/solc.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:101:18)
at Object.<anonymous> (/usr/local/lib/node_modules/solc/linker.js:7:19)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/local/lib/node_modules/solc/linker.js',
'/usr/local/lib/node_modules/solc/translate.js',
'/usr/local/lib/node_modules/solc/wrapper.js',
'/usr/local/lib/node_modules/solc/index.js',
'/usr/local/lib/node_modules/solc/solc.js'
]
}
I tried a variety of things including checking my NODE_PATH, manual installation from the solc-js GitHub, and trying to run the command with npx. However, none of these helped with the above error. For additional context, I am running on macOS Monterey. Would greatly appreciate any help regarding this.
According to this: https://github.com/ethereum/solc-js/issues/624, this is a bug introduced in 0.8.14.
It's going to be fixed in 0.8.15, in the meantime you can downgrade to 0.8.13 to avoid this.
I think it has to do with the version, I had to uninstall the current version
npm uninstall solc
npm install --save solc#0.4.25
Worked for my 2 friends (MAC M1 & W10) and me
npm uninstall solc —global
npm install —save solc#0.8.13 —global
I have webpack-cli installed on my laravel project. I don't know why first of all we need it to run my vue app but this is causing an error:
When I run npm run dev or npm run hot
[webpack-cli] Error: Cannot find module 'webpack/lib/rules/DescriptionDataMatcherRulePlugin'
Require stack:
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\vue-loader\lib\plugin-webpack5.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\vue-loader\lib\plugin.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\vue-loader\lib\index.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\laravel-mix\src\components\Vue.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\laravel-mix\src\components\ComponentRegistrar.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\laravel-mix\src\Mix.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\laravel-mix\setup\webpack.config.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\webpack-cli\lib\webpack-cli.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\webpack-cli\lib\bootstrap.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\webpack-cli\bin\cli.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\webpack\bin\webpack.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\vue-loader\lib\plugin-webpack5.js:6:42)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\vue-loader\\lib\\plugin-webpack5.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\vue-loader\\lib\\plugin.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\vue-loader\\lib\\index.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\laravel-mix\\src\\components\\Vue.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\laravel-mix\\src\\components\\ComponentRegistrar.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\laravel-mix\\src\\Mix.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\laravel-mix\\setup\\webpack.config.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\webpack-cli\\lib\\webpack-cli.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\webpack-cli\\lib\\bootstrap.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\webpack-cli\\bin\\cli.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\webpack\\bin\\webpack.js'
]
}
Vue is installed also vue-loader, can't understand why it can't find those files. Also, I looked at the node_modules everything is in there ...
You need to update your vue-loader
npm update vue-loader
And if it is not installed, install it
npm i vue-loader
Laravel added the 15.9.7 version of Vue-loader by default. I have to manually update the vue-loader:^15.9.8 in the package JSON to solve the error.
Then do yarn and yarn dev or npm install and npm run dev
I had this error in my project. After searching for it, I discovered that I have to upgrade the Vue loader. And if not installed, go ahead and install it from here. So I add this line to my terminal in my project.
npm install -D vue-loader vue-template-compiler
running
npm update vue-loader
should do the work just fine if the vue-loader package is already installed.
Some of those updates are major releases. Running npm update won’t update the version of those. Major releases are never updated in this way because they (by definition) introduce breaking changes, and npm want to save you trouble.
Some times npm packages not gets installed properly, i used following method to resolve this problem:
**
Delete node modules folder from your project.
Execute following commands
npm install -g npm-check-updates
ncu -u
npm install/update.**
Just did a minor npm update to the latest version (I can't remember what it was as npm no longer works - hence the question) but I think my installed version before the update was 5.6.0. That could be wrong though.
Anyway after running...
sudo npm install -g npm
... npm no longer works at all. Anything I do results in :
internal/modules/cjs/loader.js:596
throw err;
^
Error: Cannot find module './auth.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js:7:17)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
Any suggestions?
After trying a few different things including reinstalling node via brew the only thing that worked was to download and run the node installer binary from the node site.
Hope it helps somebody else.
I fixed this issue this way:
yarn global add npm
So I had removed node from my computer (mostly, I thought) a couple months ago, and today I reinstalled it. Node's working okay, but when I try to test npm I get this message:
$ npm
module.js:549
throw err;
^
Error: Cannot find module 'internal/util/types'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at evalmachine.<anonymous>:31:26
at Object.<anonymous> (C:\Users\LG\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\fs.js:11:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
I tried using "npm rebuild" as I've seen suggested, but that has no impact on anything. I'm using Node v8.11.2 on Windows (hell if I know what version of NPM). Any clues?
In windows,
Step 1: Go to \global_modules\node_modules,
(C:\Users\youruser\AppData\Roaming\npm )
(C:\Users\youruser\AppData\Roaming\npm-cache)
Step 2: Delete the "npm" folder and all its contents,
Step 3: Go to https://nodejs.org,
Step 4: Download the "Recommended For Most Users" version),
Step 5: Install it
For me this worked.
delete package-lock.json
npm i graceful-fs
npm i vinyl-fs
From your terminal, run
rm -rf ./node_modules
npm update
npm install npm#latest -g
or
sudo npm install npm#latest -g
These should help fix your problem.
Had this same problem. Solved it by going to %AppData% and deleting npm and npm-cache folders.
Any command I'm try to run with npm I get:
module.js:340
throw err;
^
Error: Cannot find module 'balanced-match'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/glob/node_modules/minimatch/ node_modules/brace-expansion/index.js:2:16)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
Including when I try to npm install -g balanced-match
I know this is very old, and I hope that you found your answer, but for future questors:
I saw this issue recently when I tried to use npm after upgrading node to a newer version with n.
If you recently moved to a newer version of node, and you experience the error mentioned above, you may fix it by installing the latest version of npm. As this may not be possible, because npm is used to update itself, and npm is obviously not working:
Downgrade back to an earlier version of node where your copy of npm worked.
Update npm: sudo npm install npm#latest -g
Upgrade back to the version of node you were using before.
If that doesn't work, or you think it will be easier anyway, you may have to reinstall npm from binary.
If you haven't changed versions of node recently, you may need to reinstall node, or at least npm, from their websites.
I can suggest you the following link which suggest how to install
npm balanced-match
https://www.npmjs.com/package/balanced-match
or download from
github.com/juliangruber/balanced-match