npm warn and npm start issues - javascript

I recently started coding again and I've got some issues regarding React/NodeJS (don't know which one is responsible for that)
So first things first, I installed VSCode, all clean, no errors no nothing. Then I installed NodeJS.
Now I'm just trying to create a React project for my own. I didn't install React at all as it seems it came by default after installing NodeJS. Now comes the ugly stuff.
Whenever I use the "npx create-react-app something-name" I get the following:
$ npx create-react-app demo
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
I also get some audit errors/vulnerabilities but maybe they are not so important as they get fixed after I use "audit fix --force".
So let's say that we just want to start the project.
I use cd something-name and npm start and I get this:
$ npm start
> demo#0.1.0 start
> react-scripts start
The system cannot find the path specified.
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'D:\react-scripts\bin\react-scripts.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
If anybody could help me remove those warnings from NPM and also let me know what should I do in order to start my project would be highly appreciated!

Hello there sir here are some possible fixes according to a previous question
Error: Cannot find module '\react-scripts\bin\react-scripts.js'
Check your package.json file in your project folder
delete node_modules, and package.lock.json reinstall them by
npm install
Check if your project path has a special character which is "&" just remove it
Try running a production build
//makes the production build
npm build
// runs the production build
npm run build
Finally try reinstalling node js on your system that could be the issue aswell
https://nodejs.org/en/

check your node version and make sure is updated.
remove the node-modules ()
npm install
npm start

Related

NPM Run Watch is Not Working For React Project

Hello Im trying to use NPM Run Watch so I can see localhost:3000 for my React Project but I'm getting a weird error so I don't even know where to begin.
Rubens-iMac:react-redux rubenesquivel$ npm run watch
> CodingPhase-StarterKit#1.0.0 watch /Users/rubenesquivel/Dropbox/Web Development/Web Development Courses/Coding Phase/react-redux
> gulp
fs.js:45
} = primordials;
^
ReferenceError: primordials is not defined
at fs.js:45:5
at req_ (/Users/rubenesquivel/Dropbox/Web Development/Web Development Courses/Coding Phase/react-redux/node_modules/natives/index.js:143:24)
at Object.req [as require] (/Users/rubenesquivel/Dropbox/Web Development/Web Development Courses/Coding Phase/react-redux/node_modules/natives/index.js:55:10)
at Object.<anonymous> (/Users/rubenesquivel/Dropbox/Web Development/Web Development Courses/Coding Phase/react-redux/node_modules/vinyl-fs/node_modules/graceful-fs/fs.js:1:37)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! CodingPhase-StarterKit#1.0.0 watch: `gulp`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the CodingPhase-StarterKit#1.0.0 watch script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/rubenesquivel/.npm/_logs/2021-02-20T22_29_40_150Z-debug.log
Rubens-iMac:react-redux rubenesquivel$
Not sure if anyone is familiar with this guy but I'm using codingphase starter package and before I did npm run watch I installed gulp I had some errors but I fixed using commands from stack over flow so Im worried maybe I did something to cause this on accident. I hope this makes sense.
I think I saw this error before:
First, make sure you are in the root directory of the project
Second, make sure you did run npm install
Third and most importantly, check if this project is inside another project. Meaning that you should go up level by level and check if you have a package.json file and some node_modules installed in any one of these directories:
/Users/rubenesquivel/Dropbox/Web Development/Web Development Courses/Coding Phase/
Please, let me know if this does not solve your problem
Ok I figured out what was causing the issue. The main folder I put the react project in had spaces in it. For Example I had it called Calendar web app and should have called it calendar-web-app. Yeah i know this was a rookie mistake but figure ill let everyone know in case it happens to anyone else. Thanks to everyone who took the time to help out.

Expo commands throwing "Error: Cannot find module 'minizlib'"

Whenever I try to run such commands as expo init or expo start or even just expo, it responds with:
Error: Cannot find module 'minizlib'
Require stack:
- /usr/local/lib/node_modules/expo-cli/node_modules/tar/lib/pack.js
- /usr/local/lib/node_modules/expo-cli/node_modules/tar/lib/create.js
- /usr/local/lib/node_modules/expo-cli/node_modules/tar/index.js
- /usr/local/lib/node_modules/expo-cli/node_modules/#expo/xdl/build/Extract.js
- /usr/local/lib/node_modules/expo-cli/node_modules/#expo/xdl/build/Api.js
- /usr/local/lib/node_modules/expo-cli/node_modules/#expo/xdl/build/xdl.js
- /usr/local/lib/node_modules/expo-cli/build/exp.js
- /usr/local/lib/node_modules/expo-cli/bin/expo.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:625:15)
at Function.Module._load (internal/modules/cjs/loader.js:527:27)
at Module.require (internal/modules/cjs/loader.js:683:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object.<anonymous> (/usr/local/lib/node_modules/expo-cli/node_modules/tar/lib/pack.js:28:14)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:683:19)
I have tried install and reinstalling minizlib, along with expo, expo-cli, npm, and node and nothing has worked.
Any help would be appreciated.
OS: Ubuntu 18.04.2
I had the same issue. I downgraded to version 10 of node using nvm install 10 (If you do not have NVM look into it here it is very useful) then reinstalled the expo-cli with npm install -g expo-cli. This ended up solving the issue for me.
Note: This downgrade is temporary if you want to make it your default version you have to run nvm alias default 10
I had the same issue with "minizlib" not being found. None of the solutions posted on here or other threads regarding this issue solved it.
But, I figured it out. And here is what worked for me. Its pretty straight forward.
All the modules necessary for Expo to run should be located at
/usr/local/lib/node_modules/expo-cli/node_modules/
So, go to your home directory and run npm install minizlib#2.1.0.
This will put the module file in the home directory. (I say home
directory so that the npm install doesnt clutter files into whichever
directory you were previously working on)
Now, you need to copy+paste the module folder to whichever folder npm
is looking for while running the expo command. In your case its
/usr/local/lib/node_modules/expo-cli/node_modules/
This solved the problem for me. If it worked for anyone else, please validate it for me.
install the library
npm install -g minizlib
I had the same issue and I found the way to solve it in an external forum. thanks to #parkerroanm answer there.
Anyway, here is how I solved it (from the answer I found):
I uninstalled expo-cli with this command: sudo npm uninstall -g expo-cli This is did not actually uninstall expo and nothing I could do would. So i deleted the folder with this command: sudo rm -r /usr/local/lib/node_modules/expo-cli
Then reinstalled using yarn instead with: yarn global add expo-cli --save
I updated the PATH in .bashrc to include export PATH="$(yarn global bin):$PATH" to the bottom of the file.
This fixed the issue for me.
It seems to all stem from a permissions error on installation for the
sharp library.

Can't run downloaded Angular project

I have downloaded an angular project from angular.io tutorial when i run this project
it shows error
Could not find module "#angular-devkit/build-angular" from "C:\Users\asus\angulario".
Error: Could not find module "#angular-devkit/build-angular" from "C:\Users\asus\angulario"
Could not find module "#angular-devkit/build-angular" from "C:\\Users\\asus\\angulario".
Error: Could not find module "#angular-devkit/build-angular" from "C:\\Users\\asus\\angulario".
at Object.resolve (C:\Users\asus\AppData\Roaming\npm\node_modules\#angular\cli\node_modules\#angular-devkit\core\node\resolve.js:141:11)
at Observable.rxjs_1.Observable [as _subscribe] (C:\Users\asus\AppData\Roaming\npm\node_modules\#angular\cli\node_modules\#angular-devkit\architect\src\architect.js:132:40)
at Observable._trySubscribe (C:\Users\asus\AppData\Roaming\npm\node_modules\#angular\cli\node_modules\rxjs\internal\Observable.js:44:25)
at Observable.subscribe (C:\Users\asus\AppData\Roaming\npm\node_modules\#angular\cli\node_modules\rxjs\internal\Observable.js:30:22)
at C:\Users\asus\AppData\Roaming\npm\node_modules\#angular\cli\node_modules\rxjs\internal\Observable.js:99:19
at new Promise (<anonymous>)
at Observable.toPromise (C:\Users\asus\AppData\Roaming\npm\node_modules\#angular\cli\node_modules\rxjs\internal\Observable.js:97:16)
at ServeCommand.initialize (C:\Users\asus\AppData\Roaming\npm\node_modules\#angular\cli\models\architect-command.js:88:94)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:744:11)
project live example https://stackblitz.com/angular/bvypgkmlmdv
Download link https://angular.io/generated/zips/toh-pt3/toh-pt3.zip
You haven't installed the node modules.
Kindly run the following command npm install and run the application.
You need to install the node modules first.
For that you need to run npm i in the root folder of your downloaded app
(and you need also to have npm installed)
First install NodeJS to your computer, then install npm package manager using global key,
npm i npm -g
And afer that you can install npm packages depending your package.json file as answered previous message.
npm i

Cannot find module 'npmlog' error message when using npm command

Today is my first day of my first job and after setting up my development environment by updating node and npm on my Mac (OSX) I seem to have broken something. Every time I try to use npm in my commandline (npm init, npm install, etc.) I get this error message:
module.js:339
throw err;
Error: Cannot find module 'npmlog'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:20:13
at Object. (/usr/local/lib/node_modules/npm/bin/npm->cli.js:76:3)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
There isn't much of an error message to go off and the stack trace isn't helping me all that much either. Here's what I have tried:
Searched around Stackoverflow and though there are similar problems, people have been able to use npm <something> to solve their problem, which I cannot do.
Uninstalling and reinstalling npm - Didn't work because I can't use npm command at all so things like sudo npm uninstall npm -g don't work.
Removed npmlog directory from .npm directory and then cloned the github repo directly to the directory again.
Hopefully one of you have run into this before or have an idea of how to approach it. Any help is appreciated.
Here is one good link Fixing npm On Mac OS X for Homebrew Users.
with following commands when try to upgrade node.js under mac
rm -rf /usr/local/lib/node_modules
brew uninstall node
brew install node --without-npm
echo prefix=~/.npm-packages >> ~/.npmrc
curl -L https://www.npmjs.com/install.sh | sudo sh
Here are the steps that worked for me:
$ sudo rm -rf /usr/local/bin/npm
$ sudo rm -rf /usr/local/lib/node_modules/npm
$ brew uninstall node
$ brew install node
Try curl -0 -L http://npmjs.org/install.sh | sudo sh to follow redirects. Also notice I added sudo before the sudo sh command depending on your users permissions.
I've just encountered this issue on a Mac, and on closer inspection it seems to me that the problem is that inside the Node application directory in certain circumstances the link in the node/bin directory to npm in lib/node_modules/npm/bin is replaced by the file itself and that is why it fails (and why all the various script methods fix it, because they correctly retain the file link).
If I copy the contents from node-v6.9.4-darwin-x64 with cp then I get this problem, but if I copy the files using the Finder, then I don't. So, you can fix it by manually recreating the link with ln if you don't want to use the Finder (alternatively, mv or rsync -a could work too; I haven't tested them).
Hope this helps someone coming here for this problem.
Edit: I've just accidentally found the reason for the problem on Macs (for my particular scenario, at any rate): I've always used cp -r to copy directories. This is because I am old, and don't learn new things any more. The correct way is cp -R, which correctly copies everything, as it should.
I didn't necessarily "fix" the problem as much as just start over. I used this post to do so: How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)
If anyone else knows how to actually fix the problem or knows what I did to cause it I would still be very interested.
in my condition, I just
brew uninstall node
and download from the official site and worked for me
I hit this on Fedora 27 after I ran sudo npm install npm -g.
The problem was that I had initially installed Node.js via sudo dnf install nodejs which installs npm into /usr/local/bin and /usr/local/lib. However running sudo npm install installs a separate version in /usr/bin/
Running which npm shows up that the extra npm is installed. Then the following cleaned everything for me:
$ sudo rm /usr/bin/npm
$ sudo rm -rf /usr/lib/node_modules/npm
$ dnf remove -y nodejs
$ dnf install -y nodejs
I encountered this same error. This was on a server not connected to the internet. I had seen a thread on Github that mentioned sometimes symbolic links can be removed while performing copies or other file operations. So I did a "find" on the node directory for symbolic links of the problematic server and none where found. Doing the same on a working server found symbolic link files.
I went to NODE_HOME/bin and did an ls -l
Sure enough I had a file for npm. Performed the same steps on a working server and the npm file was a symbolic link. To fix the problematic server, I performed the following:
rm npm
ln -s ../lib/node_modules/npm/bin/npm-cli.js npm
Got the same error while installing protractor in REDHAT linux updated the
npm
file at
/node-v6.10.2-linux-x64/bin/npm
for the module path as below:
Code Before
var log = require('npmlog')
Code After
var log = require('/node-v6.10.2-linux-x64/lib/node_modules/npm/node_modules/npmlog')
For me, I ran brew uninstall node and then download the latest version from nodejs.org and it worked.

grunt Cannot find module 'coffee-script'

I used the following commands to install a mean stack and create an app:
> sudo npm install -g meanio#latest // Get the mean cmdline
> mean init myApp // create your first app
> cd myApp && npm install // Install dependencies
> grunt // Launch mean
but when I get to the final grunt command I get the error:
module.js:333
throw err;
^ Error: Cannot find module 'coffee-script'
at Function.Module._resolveFilename (module.js:331:15)
at Function.Module._load (module.js:273:25)
at Module.require (module.js:357:17)
at require (module.js:373:17)
at Object.<anonymous> (/home/eddie/ResFour/node_modules/grunt/lib/grunt.js:16:1)
I've tried various solutions on stackoverflow to no avail:
NodeJS - setting up mean.io cannot find module errors
Cannot find module 'coffee-script'
I also cleared npm cache and reinstalled a few times.
Remove node_modules directory.
npm cache clean to empty downloaded temporary dependencies, just in case.
npm install again, and better not to interrupt it while running.
These solved most of these problems for me.
This worked for me:
npm install --save-dev coffee-script
node -v # v0.10.31
I had the same problem, and in the end of the log I was receiving such a message:
...
http 200 http://registry.npmjs.org/-/all
Killed
The problem was the lack of enough memory in my VM. One solution was to use swap is mentioned here.

Categories