cannot find module '#babel/generator' but it installed - javascript

i have " cannot find module '#babel/generator' " error while trying generate signed apk.
But i installed this package using yarn add, this is part of my package.json:
"dependencies": {
"#babel/cli": "^7.17.6",
"#babel/generator": "^7.17.9",
"#babel/plugin-transform-async-to-generator": "^7.16.8",
and my package lock json:
"dependencies": {
"#ampproject/remapping": "^2.1.0",
"#babel/code-frame": "^7.16.7",
"#babel/generator": "^7.17.9",
and many match when i use ctrl+f in package.lock.json and search babel/generator

I received the same error when i was trying to install the dependencies of my project.
Solution:
Delete the node_modules folder of the project
Remove the yarn.lock or package.lock file from your project
Install the dependencies again, by using yarn or npm install command.
The above steps fixed my error with the #babel/generator.

Simply delete the node_modules folder and re-install all the packages by running npm install or yarn install.
If the error persists, simply install the #babel/generator package to your project or globally.
Check out the package and installation guide here

in my case it solved by this command
yarn install --check-files
and then restart the dev server
Verifies that already installed files in node_modules did not get removed
Good luck

Related

cannot find babel-runtime library

When I am running yarn test:watch, I am getting this error.
Cannot find module 'babel-runtime/helpers/toConsumableArray' from 'node_modules/pandas-js/dist/core/series.js'
Require stack:
node_modules/pandas-js/dist/core/series.js
node_modules/pandas-js/dist/core/index.js
node_modules/pandas-js/dist/index.js
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:306:11)
at Object.<anonymous> (node_modules/pandas-js/dist/core/series.js:8:27)
I tired
npm install --save-exact #babel/runtime#7.0.0-beta.55
and then deleted node-modules folder and package-lock.json file and tried npm install again
That did not solve the issue too. Can anyone help me in this please.
This is the version of pandas-js library
"pandas-js": "^0.2.4",
in my package.json
it works after I installed babel-cli, a lot of people have said this works for them #babel/runtime#7.0.0-beta.55, but for me babel-cli helped.
you can try simply deleting the node-modules folder from your project directory, and run npm install command can also use yarn to re-install the dependencies in your project

An unhandled exception occurred: Could not find module "#angular-devkit/build-angular"

When running the terminal commands ng server or ng serve I'm getting this issue:
An unhandled exception occurred: Could not find module "#angular-devkit/build-angular"
Check in your package.json to see if you have this package in your devDependencies section or not
"devDependencies": {
"#angular-devkit/build-angular": "~0.803.18"
}
If exist try to
delete package-lock.json or yarn-lock.json
run
npm cache clean --force
then run
npm i
Install #angular-devkit/build-angular as dev dependency.
npm install --save-dev #angular-devkit/build-angular
or,
yarn add #angular-devkit/build-angular --dev
This error (Unhandled exception for a module) occurs when node_modules folder does not exist inside the project, or when the folder exists, but does not contain all the dependencies downloaded.
$ npm install command will download all the dependencies into the node_modules folder of the proejct.
npm install is automatically triggered in the background by the 'ng new', at the time of creation of the angular project.
The other angular commands like 'ng build' or 'ng serve' commands assume that 'ng new' had completed successfully.
If, for some reason, the npm install failed at the time of creation, or if the node_modules folder got deleted after the project was created, then the other angular commands (ng serve, ng build, ...) will generate this 'Unhandled Exception'.
Manually executing the npm install command inside the project will download the dependencies and fix the issue.
try this
npm install --save-dev #angular-devkit/build-angular
Make sure "#angular-devkit/build-angular": "~0.10.0" is available in devDependencies of package.json before running npm install in your angular root directory.

Npm module not found

I'm running an Angular app built with Grunt and using Bower and NPM.
I tried installing my npm module locally. The files are in the main app directory in node_modules folder.
The module docs ask me to load the module with <script type="text/javascript" src="node_modules/moment/moment.js"></script>, but I get 404.
Am I missing something? Do I have to tell Grunt that I want these NPM modules?
Can you provide more information on what your app is built with? If node serves your app, you need to make the directory you link to public. Assuming you're using express, this would look something like this in your app.js file:
app.use('/node_modules', express.static(__dirname + '/node_modules/moment/moment.js'));
Edit:
Or if you just want to make it work, try to load moment.js from CDN like this:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.js"></script>
Link to moment on CDN
Basically, npm is the package manager for all the javaScript frameworks such as Nodejs, angularjs etc. npm should be installed globally in the machine.You can install it from https://nodejs.org/en/ .
Next,you need check for the package.json file in your project.
If there is a package.json already existing in your project folder, then from command line you need to go to your project folder and type npm start.
If package.json file does not exist, then in the command line type npm init,then there will be a package.jsonfile created in your project folder.Then edit the package.json . and add the node packages into the package.json as similar way to this
{
"name": "shoppingkart",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www" //If you have any scripts.
},
"dependencies": {
"mongoose": "^4.9.0", // here you should have all your node_modules listed
"passport": "^0.3.2",
"stripe": "^4.15.1"
}
}
if you are not able to add the dependencies to json file, there is also another way to do it.
just go to your project directory in the command line and type
npm install --save grunt // And you need to do for all the node_modules, by replacing the **grunt**.
Automatically the dependency will be added to your package.json file.
If you installed your npm packages locally then your node_modules folder should found at the root of your project.
If you installed all your packages globally you may not see an npm_modules folder in your project.
To see where your global modules are located you can run
npm list -g
I faced the same issue just install the package globally and save at the end.
Like:
npm install -g <package> --save
Even the above doesn't work then use -f / --force at the end to force install.

Npm - update and save both deps and depsDev in 1 command line?

I want to update multiple npm dependecies and save them to the respective package.json dependency slot.
My package.json:
{
"dependencies": {
"gulp": "^3.0.0"
},
"devDependencies": {
"gulp-eslint": "^2.8.0"
}
}
So i want to run:
$ npm update gulp gulp-eslint
That's ok but how to save the newer versions both for gulp (dep) and gulp-eslint (devDep) respectively ?
I tried:
$ npm update gulp gulp-eslint --save
but gulp-eslint is devDependency actually must be saved there, how to do all this in 1 command line?
You can check the official documentation for npm-update and notice that there are different specifications according to the npm version you are using.
From the command line you can do:
$ npm update --save --dev
Note: Use sudo if your are on Linux or Mac.
You can also use Yarn, which is a new package manager, with this command:
yarn upgrade
https://yarnpkg.com/en/docs/cli/upgrade

Why "ionic serve" does not run once I open project directory?

It doesn't work as an internal or external system command, once I open up my project directory to run "ionic serve". Even though "ionic" is recognized as a system command. I have searched the internet but haven't found an answer yet that solves the problem.
Try a global installation using option "-g" :
npm install -g ionic or npm install -g cordova
Delete data out of the cache folder, update npm and then install Ionic/Cordova. After that try to run ionic serve.
npm cache clean
npm update -g
npm install -g ionic cordova

Categories

Resources