Getting started with NPM - node.js

I'm trying to get started with ReactJS on an existing project. I'm following instructions here to install NodeJS and Babel, but failing at the second step.
I have installed NodeJS on Windows, correctly as far as I can tell. I've navigated my terminal to the root folder of my Flask app and typed npm init -y. This generates a package.json file in the root of my app. I think this is correct so far.
However, when I try to run the next command in the instructions npm install babel-cli#6 babel-preset-react-app#3 I receive the following error:
(venv) PS C:\Users\Rob\Dropbox\Andon\andon> npm install babel-cli#6 babel-preset-react-app#3
npm ERR! code MODULE_NOT_FOUND
npm ERR! path C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\yallist\package.json
npm ERR! Cannot find module 'C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\yallist\yallist.js'. Please verify that the package.json has a valid "main" entry
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Rob\AppData\Roaming\npm-cache\_logs\2020-04-20T12_55_30_568Z-debug.log
In fact, I receive that error when I try to run any npm install commands. I assume there is some problem with how I've setup NPM, but this is my first time using it and I have no idea.
Any help would be appreciated, please.
EDIT: This is the full log of the error:
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'babel-cli#6',
1 verbose cli 'babel-preset-react-app#3'
1 verbose cli ]
2 info using npm#6.14.4
3 info using node#v12.16.2
4 verbose stack Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\yallist\yallist.js'. Please verify that the package.json has a valid "main" entry
4 verbose stack at tryPackage (internal/modules/cjs/loader.js:319:19)
4 verbose stack at Function.Module._findPath (internal/modules/cjs/loader.js:703:18)
4 verbose stack at Function.Module._resolveFilename (internal/modules/cjs/loader.js:967:27)
4 verbose stack at Function.Module._load (internal/modules/cjs/loader.js:862:27)
4 verbose stack at Module.require (internal/modules/cjs/loader.js:1042:19)
4 verbose stack at require (internal/modules/cjs/helpers.js:77:18)
4 verbose stack at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\minipass\index.js:3:17)
4 verbose stack at Module._compile (internal/modules/cjs/loader.js:1156:30)
4 verbose stack at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
4 verbose stack at Module.load (internal/modules/cjs/loader.js:1000:32)
4 verbose stack at Function.Module._load (internal/modules/cjs/loader.js:899:14)
4 verbose stack at Module.require (internal/modules/cjs/loader.js:1042:19)
4 verbose stack at require (internal/modules/cjs/helpers.js:77:18)
4 verbose stack at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\lib\extract-stream.js:3:18)
4 verbose stack at Module._compile (internal/modules/cjs/loader.js:1156:30)
4 verbose stack at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
5 verbose cwd C:\Users\Rob\Dropbox\Andon\andon
6 verbose Windows_NT 10.0.18362
7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "babel-cli#6" "babel-preset-react-app#3"
8 verbose node v12.16.2
9 verbose npm v6.14.4
10 error code MODULE_NOT_FOUND
11 error path C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\yallist\package.json
12 error Cannot find module 'C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\yallist\yallist.js'. Please verify that the package.json has a valid "main" entry
13 verbose exit [ 1, true ]

Sometimes such problems are related to the fact Node is installed in a path with spaces ( ie "Program Files" ) try to install somewhere else in a folder without spaces.

Related

npm ERR! Cannot find module 'spdx-expression-parse'

This error occurred while command npm run watch was in process, I tried to solve it with different tactics but can't find any solution
Steps which I tried to resolve the issue
1) Remove node module, package-lock.json, yarn.lock npm cache clear and the run npm install but error still occurs.
2) Remove nodejs from control panel and reinstall with latest and then old/previous version and the reinstall but can't succeed, error still occurs.
npm ERR! code MODULE_NOT_FOUND npm ERR! Cannot find module
'spdx-expression-parse'
npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\DELL\AppData\Roaming\npm-cache_logs\2018-12-20T08_00_01_749Z-debug.log
Log File
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\DELL\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install' ]
2 info using npm#6.5.0
3 info using node#v8.12.0
4 verbose stack Error: Cannot find module 'spdx-expression-parse'
4 verbose stack at Function.Module._resolveFilename (module.js:548:15)
4 verbose stack at Function.Module._load (module.js:475:25)
4 verbose stack at Module.require (module.js:597:17)
4 verbose stack at require (internal/module.js:11:18)
4 verbose stack at Object.<anonymous> (C:\Users\DELL\AppData\Roaming\npm\node_modules\npm\node_modules\validate-npm-package-license\index.js:1:75)
4 verbose stack at Module._compile (module.js:653:30)
4 verbose stack at Object.Module._extensions..js (module.js:664:10)
4 verbose stack at Module.load (module.js:566:32)
4 verbose stack at tryModuleLoad (module.js:506:12)
4 verbose stack at Function.Module._load (module.js:498:3)
5 verbose cwd D:\it-88-lynx
6 verbose Windows_NT 10.0.17134
7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\DELL\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
8 verbose node v8.12.0
9 verbose npm v6.5.0
10 error code MODULE_NOT_FOUND
11 error Cannot find module 'spdx-expression-parse'
12 verbose exit [ 1, true ]
Atlast, I have solved the problem, the spdx-expression-parse has been corrupted located in users/AppData/Roaming/npm/node_modules/
remove node_modules
uninstall nodejs
(Start Main Step)
Go to users/AppData/Roaming and delete npm and npm-cache folders manually
(End Main Step)
then run following command
rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install
thanks for all your suppport.

angular cli not able to install, getting error as `Cannot find module 'hosted-git-info' `

I am trying to create new project using ng new but getting error as :
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'hosted-git-info'
here is the detailed log file:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\MB112830\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '--quiet' ]
2 info using npm#5.7.1
3 info using node#v8.9.4
4 verbose stack Error: Cannot find module 'hosted-git-info'
4 verbose stack at Function.Module._resolveFilename (module.js:538:15)
4 verbose stack at Function.Module._load (module.js:468:25)
4 verbose stack at Module.require (module.js:587:17)
4 verbose stack at require (internal/module.js:11:18)
4 verbose stack at Object.<anonymous> (C:\Users\MB112830\AppData\Roaming\npm\node_modules\npm\node_modules\normalize-package-data\lib\fixer.js:3:21)
4 verbose stack at Module._compile (module.js:643:30)
4 verbose stack at Object.Module._extensions..js (module.js:654:10)
4 verbose stack at Module.load (module.js:556:32)
4 verbose stack at tryModuleLoad (module.js:499:12)
4 verbose stack at Function.Module._load (module.js:491:3)
5 verbose cwd E:\Tutorials\Angular2\NG5\new-way
6 verbose Windows_NT 10.0.10240
7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\MB112830\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "--quiet"
8 verbose node v8.9.4
9 verbose npm v5.7.1
10 error code MODULE_NOT_FOUND
11 error Cannot find module 'hosted-git-info'
12 verbose exit [ 1, true ]
what is the issue here? how to solve this?
It is because the files are corrupted or deleted.So follows the below steps.
1.Uninstall node.
2.Delete npm and npm-cache folder from C:\Users\userName\AppData\Roaming
3.Install node.
It works!.
Hi as i can see your project in E: drive please try to install angular in C drive globally.
npm install -g #angular/cli
after installation please create a project folder name(client) by
c://>ng new client
after creation of new project go inside client folder
C:// > cd client
c:// > client>ng serve
Open browser with localhost:4200 you can see your angular home page in running mode.
:)Cheers

npm: "Cannot find module internal/errors"

On a MacBook with the latest version of NodeJS, I am trying to update npm:
npm install npm#latest
The error message is:
npm ERR: code MODULE_NOT_FOUND
npm ERR: Cannot find module 'internal/errors'
npm ERR: A complete log of this run can be found in:
npm ERR: /Users/alexander/.npm/_logs/2017_09_15_12_35_47_079Z-debug.log
and the referenced log file reads
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli 'npm#latest' ]
2 info using npm#5.3.0
3 info using node#v8.5.0
4 verbose npm-session 5db7f116200ca64c
5 verbose stack Error: Cannot find module 'internal/errors'
5 verbose stack at Function.Module._resolveFilename (module.js:527:15)
5 verbose stack at Function.Module._load (module.js:476:23)
5 verbose stack at Module.require (module.js:568:17)
5 verbose stack at require (internal/module.js:11:18)
5 verbose stack at evalmachine.<anonymous>:36:16
5 verbose stack at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/cmd-shim/node_modules/graceful-fs/fs.js:11:1)
5 verbose stack at Module._compile (module.js:624:30)
5 verbose stack at Object.Module._extensions..js (module.js:635:10)
5 verbose stack at Module.load (module.js:545:32)
5 verbose stack at tryModuleLoad (module.js:508:12)
5 verbose stack at Function.Module._load (module.js:500:3)
5 verbose stack at Module.require (module.js:568:17)
5 verbose stack at require (internal/module.js:11:18)
5 verbose stack at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/cmd-shim/node_modules/graceful-fs/graceful-fs.js:3:27)
5 verbose stack at Module._compile (module.js:624:30)
5 verbose stack at Object.Module._extensions..js (module.js:635:10)
6 verbose cwd /Users/alexander/Documents/Source/Repos
7 verbose Darwin 16.7.0
8 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "npm#latest"
9 verbose node v8.5.0
10 verbose npm v5.3.0
11 error code MODULE_NOT_FOUND
12 error Cannot find module 'internal/errors'
13 verbose exit [ 1, true ]
The same worked ok on the windows machine.
What is the problem and how can I fix this?
Try to reinstall npm from the package in node v6.11.3LTS, and then
try to update to the latest npm v5.4.2
npm install npm#latest -g
and then update to the latest node v8.3.0
npm install node#latest -g
I had the same issue, the above answer did not work.
I had old versions in node_modules.
I simply deleted everything in node_modules and then ran:
npm install npm#latest -g
I had the same problem, and I solve it:
uninstall node and npm, do as this answer.
then install node
brew install node
and npm will also be installed.

How to solve error: Cannot find module 'json-parse-helpfulerror'

In Windows, I tried to create a new application form of this site: https://facebook.github.io/react/docs/installation.html
First, I installed Node.js v8.2.1 and when I execute npm install -g create-react-app, I get the following error:
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'json-parse-helpfulerror'
npm-debug.log:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\mushou8\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'create-react-app' ]
2 info using npm#5.2.0
3 info using node#v6.11.2
4 verbose stack Error: Cannot find module 'json-parse-helpfulerror'
4 verbose stack at Function.Module._resolveFilename (module.js:469:15)
4 verbose stack at Function.Module._load (module.js:417:25)
4 verbose stack at Module.require (module.js:497:17)
4 verbose stack at require (internal/module.js:20:19)
4 verbose stack at Object.<anonymous> (C:\Users\mushou8\AppData\Roaming\npm\node_modules\npm\node_modules\read-package-json\read-json.js:12:16)
4 verbose stack at Module._compile (module.js:570:32)
4 verbose stack at Object.Module._extensions..js (module.js:579:10)
4 verbose stack at Module.load (module.js:487:32)
4 verbose stack at tryModuleLoad (module.js:446:12)
4 verbose stack at Function.Module._load (module.js:438:3)
5 verbose cwd C:\Users\mushou8
6 verbose Windows_NT 6.1.7601
7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\mushou8\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "create-react-app"
8 verbose node v6.11.2
9 verbose npm v5.2.0
10 error code MODULE_NOT_FOUND
11 error Cannot find module 'json-parse-helpfulerror'
12 verbose exit [ 1, true ]
In the directory folder, issue the following command:
npm update
Remove npm and reinstall it
And run:
sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm*
Seeing what is requested in the Users folder, it seems that it should be installed as a global package.
Check and install each required package.
npm i -g json-parse-helpfulerror
You must uninstall nodejs and npm packages.
after first, you must install npm.
and you should install "npm install --save json-parse-better-errors"
Finally you can run your project
https://www.npmjs.com/package/json-parse-better-errors
I fixed it by removing the node_modules folder and reinstalling it again. To remove the folder, go to your project folder and run $ rm -rf node_modules and then reinstall your packages using your preferred package manager, either npm i or yarn install.

sudo npm install -g react-native ERR!Cannot find module './spawn'

npm error when I try to build the React Native environment with Mac.
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'react-native' ]
2 info using npm#2.15.9
3 info using node#v4.6.0
4 verbose stack Error: Cannot find module './spawn'
4 verbose stack at Function.Module._resolveFilename (module.js:325:15)
4 verbose stack at Function.Module._load (module.js:276:25)
4 verbose stack at Module.require (module.js:353:17)
4 verbose stack at require (internal/module.js:12:17)
4 verbose stack at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:6:13)
4 verbose stack at Module._compile (module.js:409:26)
4 verbose stack at Object.Module._extensions..js (module.js:416:10)
4 verbose stack at Module.load (module.js:343:32)
4 verbose stack at Function.Module._load (module.js:300:12)
4 verbose stack at Module.require (module.js:353:17)
4 verbose stack at require (internal/module.js:12:17)
5 verbose cwd /Users/BigGIfts
6 error Darwin 15.6.0
7 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "react-native"
8 error node v4.6.0
9 error npm v2.15.9
10 error code MODULE_NOT_FOUND
11 error Cannot find module './spawn'
12 error If you need help, you may report this error at:
12 error <https://github.com/npm/npm/issues>
13 verbose exit [ 1, true ]
The correct way to build the react-native:
npm install -g react-native-cli
If you get an error like:
Cannot find module 'npmlog'
Try installing npm directly: curl -0 -L https://npmjs.org/install.sh | sudo sh
Note: when the error cannot find ... is anywhere in the error log and you did install it, it's probably either in the wrong directory or you haven't installed it yet.
Hope this helps you out ;)

Resources