Error: Cannot find module 'code-point-at' while writing any npm commands - node.js

Configurations:
System : Ubuntu v21.10
node : v16.14.0
npm : v6.13.7
Problem :
It was working well until last ubuntu software update,Now its throwing "Error: Cannot find module 'code-point-at' while writing any npm commands" because of code: 'MODULE_NOT_FOUND'
I have attached terminal Screenshot,please help me solve this issue.
Terminal:
Terminal Screenshot
ssns#nits-hp-15-notebook-pc:~$ npm --version
node:internal/modules/cjs/loader:933
const err = new Error(message);
^
Error: Cannot find module 'code-point-at'
Require stack:
- /usr/lib/node_modules/npm/node_modules/wide-align/node_modules/string-width/index.js
- /usr/lib/node_modules/npm/node_modules/wide-align/align.js
- /usr/lib/node_modules/npm/node_modules/gauge/lib/render-template.js
- /usr/lib/node_modules/npm/node_modules/gauge/lib/plumbing.js
- /usr/lib/node_modules/npm/node_modules/gauge/lib/index.js
- /usr/lib/node_modules/npm/node_modules/npmlog/lib/log.js
- /usr/lib/node_modules/npm/lib/utils/log-shim.js
- /usr/lib/node_modules/npm/lib/utils/exit-handler.js
- /usr/lib/node_modules/npm/lib/cli.js
- /usr/lib/node_modules/npm/bin/npm-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:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/wide-align/node_modules/string-width/index.js:3:19)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/lib/node_modules/npm/node_modules/wide-align/node_modules/string-width/index.js',
'/usr/lib/node_modules/npm/node_modules/wide-align/align.js',
'/usr/lib/node_modules/npm/node_modules/gauge/lib/render-template.js',
'/usr/lib/node_modules/npm/node_modules/gauge/lib/plumbing.js',
'/usr/lib/node_modules/npm/node_modules/gauge/lib/index.js',
'/usr/lib/node_modules/npm/node_modules/npmlog/lib/log.js',
'/usr/lib/node_modules/npm/lib/utils/log-shim.js',
'/usr/lib/node_modules/npm/lib/utils/exit-handler.js',
'/usr/lib/node_modules/npm/lib/cli.js',
'/usr/lib/node_modules/npm/bin/npm-cli.js'
]
}
ssns#nits-hp-15-notebook-pc:~$
Thanks in Advance.. :)

I have the same issue on Windows - even npm -v would throw the same error. I'm unable to find the root cause of the issue, but found the following workaround.
I found out that the folder at Program Files\nodejs\node_modules\npm\node_modules\code-point-at was empty for me, even after a clean install of Node. In your case, the directory should be /usr/lib/node_modules/npm/node_modules/code-point-at.
I downloaded a copy of code-point-at from its Github repository at https://github.com/sindresorhus/code-point-at/tags, and manually copied the files into the directory. Once this was done, NPM appears to function normally for me.

Related

No definite solution on Windows for Cannot find module 'graceful-fs' Error on React Native App Create Start Up

`PS C:\Users\Adrien\Documents\ReactNativeProjects> npx react-native start
node:internal/modules/cjs/loader:1042
throw err;
^
Error: Cannot find module 'graceful-fs'
Require stack:
- C:\Users\Adrien\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\tools\gracefulifyFs.js
- C:\Users\Adrien\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\bin.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
at Module._load (node:internal/modules/cjs/loader:885:27)
at Module.require (node:internal/modules/cjs/loader:1105:19)
at require (node:internal/modules/cjs/helpers:103:18)
at _gracefulFs (C:\Users\Adrien\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\tools\gracefulifyFs.js:15:39)
at Object.<anonymous> (C:\Users\Adrien\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\tools\gracefulifyFs.js:22:1) at Module._compile (node:internal/modules/cjs/loader:1218:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
at Module.load (node:internal/modules/cjs/loader:1081:32)
at Module._load (node:internal/modules/cjs/loader:922:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Adrien\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\build\\tools\\gracefulifyFs.js',
'C:\\Users\\Adrien\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\build\\bin.js'
]
}
Node.js v18.13.0
Everytime I tried to create an App I got this as a response.
I tried to Open a Project like,
npx react-native init App2
I was expecting was for the project to get built, appear so that I could see all the project files.
I tried uninstalling and then reinstalling like,
npm install 'graceful-fs'
I tried the other solutions here too like apt-get or sudo and curl but it didn't work in my terminal`

how to solve this err in hardhat vs code

You are using a version of Node.js that is not supported by Hardhat,
and it may work incorrectly, or not work at all. Please, make sure you
are using a supported version of Node.js. To learn more about which
versions of Node.js are supported go to
https://hardhat.org/nodejs-versions
An unexpected error occurred:
Error: Cannot find module '#nomiclabs/hardhat-waffle'
Require stack:
- D:\3.1\dppa\hardhat.config.js
- D:\3.1\dppa\node_modules\hardhat\internal\core\config\config-loading.js
- D:\3.1\dppa\node_modules\hardhat\internal\cli\cli.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:939:15)
at Function.Module._load (node:internal/modules/cjs/loader:780:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (D:\3.1\dppa\hardhat.config.js:1:1)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:827:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'D:\\3.1\\dppa\\hardhat.config.js',
'D:\\3.1\\dppa\\node_modules\\hardhat\\internal\\core\\config\\config-loading.js',
'D:\\3.1\\dppa\\node_modules\\hardhat\\internal\\cli\\cli.js'
]
}
PS D:\3.1\dppa>
It looks like you are trying to run the sample project and are missing plugins.
As stated here, you need to install some plugins for the sample project with the following command.
npm install --save-dev #nomiclabs/hardhat-waffle ethereum-waffle chai #nomiclabs/hardhat-ethers ethers
Besides that, as stated in the provided link, you should use the latest LTS of Node.js, which is Node.js 16 and can be downloaded here

Running Ghost in Github - Error: Cannot find module '/home/runner/work/website/website/package.json'

I'm trying to build a website using Ghost and followed the tutorial to connect it with GitHub exactly. When I run the code in the .github/workflows/main.yml file I get the error:
Run TryGhost/action-deploy-theme#v1.4.1
Error: Cannot find module '/home/runner/work/website/website/package.json'
Require stack:
- /home/runner/work/_actions/TryGhost/action-deploy-theme/v1.4.1/dist/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
at Function.Module._load (internal/modules/cjs/loader.js:690:27)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (internal/modules/cjs/helpers.js:74:18)
at main (/home/runner/work/_actions/TryGhost/action-deploy-theme/v1.4.1/dist/index.js:1560:62)
at Object.104 (/home/runner/work/_actions/TryGhost/action-deploy-theme/v1.4.1/dist/index.js:1578:2)
at __webpack_require__ (/home/runner/work/_actions/TryGhost/action-deploy-theme/v1.4.1/dist/index.js:24:31)
at startup (/home/runner/work/_actions/TryGhost/action-deploy-theme/v1.4.1/dist/index.js:43:19)
at /home/runner/work/_actions/TryGhost/action-deploy-theme/v1.4.1/dist/index.js:47:18
at Object.<anonymous> (/home/runner/work/_actions/TryGhost/action-deploy-theme/v1.4.1/dist/index.js:50:10) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/runner/work/_actions/TryGhost/action-deploy-theme/v1.4.1/dist/index.js'
]
}
If anyone knows how to fix this problem I'd appreciate you letting me know :)

Nestjs Yarn build failed Error: Cannot find module './_assignValue'

I tried to start a new project using nestjs and yarn after I run yarn install which is compeleted successfully I run yarn build and here is what I got
The Error :
$ rimraf dist
$ nest build
internal/modules/cjs/loader.js:888
throw err;
^
Error: Cannot find module './_assignValue'
Require stack:
- /home/ashraf/test-project/node_modules/lodash/_copyObject.js
- /home/ashraf/test-project/node_modules/lodash/assignIn.js
- /home/ashraf/test-project/node_modules/lodash/extend.js
- /home/ashraf/test-project/node_modules/inquirer/lib/ui/baseUI.js
- /home/ashraf/test-project/node_modules/inquirer/lib/ui/bottom-bar.js
- /home/ashraf/test-project/node_modules/inquirer/lib/inquirer.js
- /home/ashraf/test-project/node_modules/#nestjs/cli/lib/utils/project-utils.js
- /home/ashraf/test-project/node_modules/#nestjs/cli/actions/generate.action.js
- /home/ashraf/test-project/node_modules/#nestjs/cli/actions/index.js
- /home/ashraf/test-project/node_modules/#nestjs/cli/commands/command.loader.js
- /home/ashraf/test-project/node_modules/#nestjs/cli/commands/index.js
- /home/ashraf/test-project/node_modules/#nestjs/cli/bin/nest.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
at Function.Module._load (internal/modules/cjs/loader.js:730:27)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/ashraf/test-project/node_modules/lodash/_copyObject.js:1:19)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Module.require (internal/modules/cjs/loader.js:957:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/ashraf/test-project/node_modules/lodash/_copyObject.js',
'/home/ashraf/test-project/node_modules/lodash/assignIn.js',
'/home/ashraf/test-project/node_modules/lodash/extend.js',
'/home/ashraf/test-project/node_modules/inquirer/lib/ui/baseUI.js',
'/home/ashraf/test-project/node_modules/inquirer/lib/ui/bottom-bar.js',
'/home/ashraf/test-project/node_modules/inquirer/lib/inquirer.js',
'/home/ashraf/test-project/node_modules/#nestjs/cli/lib/utils/project-utils.js',
'/home/ashraf/test-project/node_modules/#nestjs/cli/actions/generate.action.js',
'/home/ashraf/test-project/node_modules/#nestjs/cli/actions/index.js',
'/home/ashraf/test-project/node_modules/#nestjs/cli/commands/command.loader.js',
'/home/ashraf/test-project/node_modules/#nestjs/cli/commands/index.js',
'/home/ashraf/test-project/node_modules/#nestjs/cli/bin/nest.js'
]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
In other hand if I tried using npm install and npm run build everything works fine !

When starting a discord bot i get this error

When starting my discord bot that I created a couple years ago I'm getting this error, I've no clue on whats causing it. I have done the uninstall of the node_modules and reinstalling etc but I'm not sure what the error could be caused by, any ideas?
Error:
PS C:\Users\Admin\Documents\Bot> node index.js
internal/modules/cjs/loader.js:960
throw err;
^
Error: Cannot find module 'better-sqlite3'
Require stack:
- C:\Users\Admin\Documents\Bot\node_modules\enmap\src\index.js
- C:\Users\Admin\Documents\Bot\node_modules\enmap\index.js
- C:\Users\Admin\Documents\Bot\index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
at Function.Module._load (internal/modules/cjs/loader.js:840:27)
at Module.require (internal/modules/cjs/loader.js:1019:19)
at require (internal/modules/cjs/helpers.js:77:18)
at new Enmap (C:\Users\Admin\Documents\Bot\node_modules\enmap\src\index.js:110:24)
at Object.<anonymous> (C:\Users\Admin\Documents\Bot\index.js:5:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Admin\\Documents\\Bot\\node_modules\\enmap\\src\\index.js',
'C:\\Users\\Admin\\Documents\\Bot\\node_modules\\enmap\\index.js',
'C:\\Users\\Admin\\Documents\\Bot\\index.js'
]
}
First make sure better-sqlite3 is installed
npm i better-sqlite3
then that it has been defined
const better-sqlite3 = require('better-sqlite3')

Resources