Cannot find module 'asap/raw' - react-native

i have started a new react-native project and after that i installed react-native-maps i can't run react-native run-android because the terminal displays the following error:
module.js:550
throw err;
^
Error: Cannot find module 'asap/raw'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/valentino/Scrivania/lolo/node_modules/promise/lib/core.js:3:12)
at Module._compile (module.js:653:30)
at Module._compile (/home/valentino/Scrivania/lolo/node_modules/pirates/lib/index.js:83:24)
at Module._extensions..js (module.js:664:10)
at Object.newLoader [as .js] (/home/valentino/Scrivania/lolo/node_modules/pirates/lib/index.js:88:7)
at Module.load (module.js:566:32)
The message is shown if i install react-native-maps, this is the command with i have built the project with:
react-native init appName
cd appName
npm install react-native-maps --save
react-native run-android
How I can resolve this problem?
Am I doing something wrong?
Thanks for the help.

Running npm install in your project directory usually works.
(What it does is that it installs all the dependencies in the local node_modules folder that may have been downloaded when you installed that one package.)

Running npm install did not solve the problem for me.
I ran npm install -g asap to install asap and then the error went away.

The react-native init command creates a project which uses yarn by default since 0.57 (has yarn.lock). I had the same error when I installed a plugin by npm install, so the conclusion is that you can't use both package manager for the same project at the same time (yarn and npm). So:
Use yarn add instead of npm install.
Or if you don't want to use yarn, then "switch" to npm by running npm install first (after this you can delete yarn.lock and you must always use npm from this point instead of yarn).

Deleting node_modules and reinstalling didn't fix but doing npm install asap in the project directory fixed my issue.

Related

Why react-native-cli giving errors?

I recently installed react native cli globally. When i tried to start a project using react-native init projectname or npx react-native init projectname it started downloading packages and creating the project. After completion it gave this error
cli.init(root, projectname);
^
typeerror: cli.init is not a function
at run (c:\users\showbi\appdata\roaming\npm\node_modules\react-native-cli\index.js:302:7)
at createproject (c:\users\showbi\appdata\roaming\npm\node_modules\react-native-cli\index.js:249:3)
at init (c:\users\showbi\appdata\roaming\npm\node_modules\react-native-cli\index.js:200:5)
at object.<anonymous> (c:\users\showbi\appdata\roaming\npm\node_modules\react-native-cli\index.js:153:7)
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:822:12)
at function.executeuserentrypoint [as runmain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
What is causing this problem?
Probably you are have and using old react-native-cli, try to:
npm uninstall -g react-native-cli or yarn global remove react-native-cli
and then run npx react-native init projectname again.
That is error is from the new version 0.69.0
You can use npx react-native init ProjectName --version 0.68.2 and then upgrade to v 0.69 later.
The quick way out is
npx react-native init ProjectName --version 0.68.2
Because that error is from the new version 0.69.0 You can use upgrade to 0.69.0 later.
But the longer route is below:
Need to clean global environments with following commands:
yarn global remove react-native
yarn global remove react-native-cli
npm uninstall -g react-native
npm uninstall -g react-native-cli
check that nothing related to react-native presents in these lists:
yarn global list
npm -g list
install new react-native global
npm install -g react-native-cli
npm install -g react-native
then you can run:
npx react-native init ProjectName
Just delete react native cli from globally and manually delete folder at:
c:\users\showbi\appdata\roaming\npm\node_modules\react-native-cli
It is work for me perfectly.
remove react-native CLI globally
(npm uninstall -g react-native-cli)
and reinstall your app
(npx react-native init app name)
Replacing npx react-native with npx react-native#latest solved it for me.

npm Error When creating vue project using Vue-CLI

I am new to Vue. and searched everywhere for the correct answer. But no luck. Please Help me on this.
I can't create a new vue project.
at the first I ran npm install -g #vue/cli
and after that vue create vue-animated-ui
But it gives an error,
C:\Users\User\AppData\Roaming\nvm\v10.22.0\node_modules\#vue\cli\node_modules\execa\index.js:347
throw err;
^
Error: Command failed: npm --version
'npm' is not recognized as an internal or external command,
operable program or batch file.
at makeError (C:\Users\User\AppData\Roaming\nvm\v10.22.0\node_modules\#vue\cli\node_modules\execa\index.js:174:9)
at Function.module.exports.sync (C:\Users\User\AppData\Roaming\nvm\v10.22.0\node_modules\#vue\cli\node_modules\execa\index.js:338:15)
at new PackageManager (C:\Users\User\AppData\Roaming\nvm\v10.22.0\node_modules\#vue\cli\lib\util\ProjectPackageManager.js:126:42)
at Object.<anonymous> (C:\Users\User\AppData\Roaming\nvm\v10.22.0\node_modules\#vue\cli\lib\util\getVersions.js:6:12)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
npm version 6.14.6 and vue cli version #vue/cli 4.5.13
Thank you in advance.
Ah! base the file path looks like you are using NVM control the node version.
So I think this issue is not vue/cli issue. it's an nvm issue.
And base on the error message it's npm v can not execute.
I suggest you first check in this path
C:\Users\User\AppData\Roaming\nvm\v10.22.0\node_modules\
Do you have the npm folder like this:
If not it means when you use nvm use 10.22.0 it does not install the npm.
So you can install manually
this is the node npm version: nodejs.org
node v10.22.0 should use npm v6.14.6
go to npm download the 6.14.6 version.
unzip it to your path C:\Users\User\AppData\Roaming\nvm\v10.22.0\node_modules\ and rename it to npm
then try npm -v if you got version. means it's work. it'll also work for vue/cli

gulp command error : cannot find module 'through2'?

I installed the gulp to global and local project:
npm install -g gulp
and
npm install --save-dev gulp
then I use gulp command:
gulp -v
then,display error:
module.js:471
throw err;
^
Error: Cannot find module 'through2'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/users/zhangzhida/output/lib/node_modules/gulp/node_modules/gulp-util/lib/noop.js:1:77)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
Then ,I install the through2 to global and local project. still display error like
the above. when I re-install the gulp after installed the through2 ,is also like the above.
I think it is some problem in npm ,but I don't know how to resolve it .Please help me.
While I'm not sure if it will help, here's how to use gulp.
Update NodeJS and npm
If not done already, install the latest stable version of NodeJS and immediately run:
npm install -g npm
This will update npm with npm.
Installing gulp
The first thing you see on their website is the npm commands to install the gulp package to your local project, and the gulp CLI program globally as a tool.
npm install gulp-cli -g
npm install gulp -D
Since so much people confuses the gulp package with the gulp CLI package, the doc says:
If you've previously installed gulp globally, run npm rm --global gulp
before [installing the CLI again]
Using gulp with a project
Gulp is a development dependency in your project, like any other package needed to build your project. So you shouldn't install through2 globally, only locally in the project as a dev dependency.

Cannot find module 'glob'

Tell me what extra information you need
Im following a simple guide to activate my first angular 2 app and did the following actions on the clr:
npm i -g angular-cli //(worked)
ng new ponyracer //(error: Cannot find module 'glob')
ng serve //(error: Cannot find module 'glob')
Cannot find module 'glob'
Error: Cannot find module 'glob'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (C:\Users\stavalfi\AppData\Roaming\npm\node_modules\angular-cli\addon\ng2\tasks\lib-install.js:11:19)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
Any explations about the commands "ng new ponyracer" and "ng serve" will be great.
Thanks,
Stav
There's already an issue reporting this error message. The workaround until the next release is to install glob for the project (npm install --save glob)
Regarding the commands, according to their repository under Generating and serving an Angular2 project via a development server the commands are as follow
ng new ponyracer : This command will create a project named ponyracer (a folder named ponyracer with all the set up in it).
ng serve : This command will run the live reload server to serve the application so you can see it in your browser.
PS : If you test the solution suggested in the issue it would be nice of you to report if it worked or not.
PS2 : I tested now (I fixed my error) and I cannot reproduce your error. I'm using node v5.5.0 and npm v3.7.3. Can you specify which node and npm versions are you using?
I had the same error on Windows 10,
D:\Code\AngularJS>ng new greetings-ac
Cannot find module 'glob'
Error: Cannot find module 'glob'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (D:\Code\node_modules\angular-cli\addon\ng2\tasks\lib-install.js:11:19)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
but the following fixed it:
D:\Code\AngularJS>npm install -g angcli
D:\Code\AngularJS>ng new greetings-ac
? Select project blueprint: Default template
Cloning into 'D:\Code\AngularJS\greetings-ac'...
install installing using npm
npm WARN package.json angularApp#0.0.0 No description
npm WARN package.json angularApp#0.0.0 No repository field.
npm WARN package.json angularApp#0.0.0 No README data
npm WARN deprecated lodash-node#2.4.1: This package has been discontinued in favor of lodash#^4.0.0.
npm WARN optional dep failed, continuing fsevents#1.0.7
npm WARN deprecated lodash-node#3.10.2: This package has been discontinued in favor of lodash#^4.0.0.
npm WARN optional dep failed, continuing fsevents#1.0.7
For now, run npm install --save glob in your project, or install globally npm install -g glob like Eric mentioned.
This is listed in Issue #233 on the angluar-cli project.
The missing glob dep has been fixed in latest master. This will go out
in the next release. - posted 4/21/16
Versions ran with this fix:
angular-cli: 0.0.33
node: 5.9.1
glob: 7.0.3
angular2: 2.0.0-beta.14
I had the same issue.
Cannot find module 'module_name'
Error: Cannot find module 'module_name'
When I run the command:
npm install --save module_name
Note: Here the 'module_name' is the name of the missing module. example: fs-extra, glob, dependency-graph, sort-package-json, #phosphor/coreutils, prettier etc.
It throws a new error that a new module is missing. And it kept happening everytime I try to fix an error, a new error pops up the next time(other packages mentioned above).
Here's what I did to solve the error:
I had to uninstall and unlink nodejs and npm :
Note: use unlink only if you have linked them before, otherwise, it's not necessary
brew uninstall node
brew unlink node
brew unlink npm
brew unlink node_modules
Make sure you remove all the node_modules, npm and nodejs folders from your system.
My commands below can be different from yours. You can manually search for folders and remove them as well:
rm -rf /usr/local/lib/node_modules
sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}
sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* /usr/local/lib/dtrace/node.d ~/.npm ~/.node-gyp
After uninstalling and deleting all node, npm folders, I ran these commands:
brew install node
npm install yarn -g
npm install -g typescript
npm install
yarn install
That fixed all the issues
remove node_modules
remove package-lock.json
npm i
npm run ...

How to use globally installed gulp modules?

I tried this tutorial to basically setup my gulp project and activate less processing and watching. It works. Now I'd like to install the modules globally, in order to acces them from everywhery on the machine and not to installa them for every project:
npm install --global gulp-less
npm install --global gulp-watch
npm install --global gulp-autoprefixer
npm install --global gulp-plumber
Now I want to run gulp in my project folder, but gulp cannot find the globally installed modules:
$ cd /my/project
$ gulp
module.js:327
throw err;
^
Error: Cannot find module 'gulp-less'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/root/temp/gulptest/gulpfile.js:9:12)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
How to get it working and use global gulp modules?
The solution was npm-link. I had to link all my local packages to global counterparts:
npm link gulp
npm link gulp-less
npm link gulp-watch
npm link gulp-autoprefixer
npm link gulp-plumber
npm link path
Now it works.
Some StackOverflow posts to this subject:
"Skip local installation of Gulp"
Aperçu's answer
"Why do we need to install gulp globally and locally?"
Derek Greer's answer
1. Install gulp globally:
If you have previously installed a version of gulp globally, please run npm rm --global gulp
to make sure your old version doesn't collide with gulp-cli.
$ npm install --global gulp-cli
2. Install gulp in your project devDependencies:
$ npm install --save-dev gulp
Read more... https://github.com/gulpjs/gulp/blob/master/docs/getting-started.md
For what it's worth, I solved this by placing this line at the top of my gulpfile.js
module.paths = module.paths.concat(module.parent.paths);
My parent module knew my npm global directory, but while running gulpfile.js, a child module seems to be created which doesn't. Instead, module paths is only relevant to the current directory from where the project is being run from and then each previous directory back to the root of my drive.