Angular project creation failed because of deprecated circular-json - javascript

I used following command to create new angular project
ng new hello-world
It failed showing
npm WARN deprecated circular-json#0.5.9: CircularJSON is in maintenance only, flatted is its successor.
npm ERR! Unexpected end of JSON input while parsing near '...rocess":"~0.7.0"},"_h'
Then I installed flatted using...
npm i flatted
But the error still occurs.
How to use flatted instead of deprecated library circular-json?

Run following commands that will clean NPM cache
npm cache clean --force
after this run following command
npm install -g #angular/cli#latest
then you can create angular project.

If it doesn't work, even after clearing the cache, which happened in my case:
Make sure you try the ng new create-app command using Powershell in administrator mode.
This worked for me.

I had the same problem. None of the above mentioned answers worked for me.
So I removed the content of .npmrc, ran the generate command and it worked.
After that, you can restore the content of your .npmrc if needed.

Related

Next.js: Module not found: Can't resolve 'canvg'

I have a next.js project and I keep getting:
error - ./node_modules/jspdf/dist/jspdf.es.min.js:458:25
Module not found: Can't resolve 'canvg'
I'm not sure why because I'm not including either jspdf or canvg.
Not sure what's causing it. Any help would be appreciated. I'm using material-ui if that matters.
It seems dependency error means that particular Module is missing when it's running.
Run npm ls or yarn list will print to stdout all the versions of packages that are installed, as well as their dependencies, in a tree-structure. Then search for that particulate packages are listed or not.
Run npm ls jspdf or yarn list jspdf then you can see its list of dependencies in tree-structure.
Please check your node version is updated or not ? If not then update first.
Quick & Dirty way: delete package.lock or yarn.lock file and delete .node_modules folders And Then run npm install or yarn to install again.
Look at console while you installing and make sure there are no error in the installing process. If you saw error you better look that massages also.

Uncaught ReferenceError: req is not defined with cli#1.5

Found this post that appears to resolve the issues.
https://github.com/angular/angular-cli/issues/8359
Sorry but it is not clear to me what is the next step to fix this issue?
Which version of angular cli should I upgrade to fix this?
Note that this happens in compiling in angular production mode.
This should do the trick:
npm uninstall -g angular-cli
npm cache clean
npm install -g angular-cli#1.4.9
People in the post generally mention no issues after going to CLI 1.4.9
Also, the Angular verison might need to be dropped down as well if just doing the CLI doesn't work. See jonathanbruno's comment on that page

All NPM COMMAND not working even I updated .bash_profile

I used npm for several months.
But after I install python/django and virtual environment, it's not working anymore.
The error is smething like this.
sudo npm install -g react-native-cli
module.js:341
throw err;
^Error: Cannot find module './cache/caching-client.js'
I used npm for several days but this happened first time. I searched to solve issue and found this link
Installing MEAN Stack: npm -v module.js: 338 throw err; Error: Cannot find module './cache/caching-client.js'.
But not working.
echo $NODE_PATH
/usr/local/lib/node_modules
And it occurs on all npm commands.
npm -v
npm init -y
I reinstalled the node.js again and it worked.:)
f you added React Native manually to your project, make sure you have included all the relevant dependencies that you are using, like RCTText.xcodeproj, RCTImage.xcodeproj. Next, the binaries built by these dependencies have to be linked to your app binary. Use the Linked Frameworks and Binaries section in the Xcode project settings. More detailed steps are here: Linking Libraries.
If you are using CocoaPods, verify that you have added React along with the subspecs to the Podfile. For example, if you were using the , and fetch() APIs, you would need to add these in your Podfile:
for more see this
https://www.npmjs.com/package/react-native-winjs-cli/tutorial

npm - EPERM: operation not permitted on Windows

I ran
npm config set prefix /usr/local
After running that command,
When trying to run any npm commands on Windows OS I keep getting the below.
Error: EPERM: operation not permitted, mkdir 'C:\Program Files (x86)\Git\local'
at Error (native)
Have deleted all files from
C:\Users\<your username>\.config\configstore\
It did not work.
Any suggestion ?
Running this command was my mistake.
npm config set prefix /usr/local
Path /usr/local is not for windows. This command changed the prefix variable at 'C:\Program Files (x86)\Git\local'
To access and make a change to this directory I need to run my cmd as administrator.
So I did:
Run cmd as administrator
Run npm config edit (You will get notepad editor)
Change prefix variable to C:\Users\<User Name>\AppData\Roaming\npm
Then npm start works in a normal console.
This is occurring because windows is not giving permission to the user to create a folder inside system drive. To solve this:
Right Click
The Folder > Properties > Security Tab
Click on Edit to change Permissions > Select the user and give Full Control to that user.
Sometimes, all that's required is to stop the dev server before installing/updating packages.
I solved the problem by changing windows user access for the project folder:
Here is a screenshot:
http://prntscr.com/djdn0g
Restarting VsCode solved it for me!
I recently had the same problem when I upgraded to the new version, the only solution was to do the downgraded
To uninstall:
npm uninstall npm -g
Install the previous version:
npm install npm#5.3 -g
Try update the version in another moment.
I use Windows 10.
I started the CMD as administrator, and it solved the problem.
Find CMD, right click, and click open as administrator.
I had an outdated version of npm. I ran a series of commands to resolve this issue:
npm cache clean --force
Then:
npm install -g npm#latest --force
Then (once again):
npm cache clean --force
And finally was able to run this (installing Angular project) without the errors I was seeing regarding EPERM:
ng new myProject
In my case, I was facing this error because my directory and its file were opened in my editor (VS code) while I was running npm install. I solved the issue by closing my editor and running npm install through the command line.
I had the same problem, after updating npm. Solved it by re-installing latest npm again with:
npm i -g npm
but this time with cmd running in administrating mode.
i did all this because i suspected there was an issue with the update, mostly some missing files.
I had the same problem when I tried to install the npm package AVA. The solution for me was to delete the node_modules folder and force-clean the npm cache:
rm -rf node_modules
npm cache clean --force
I could then install the npm package without a problem.
for me it was an issue of altering existing folders in node_module, so i nuked the whole folder and run npm install again. it works with no errors after that
Just run cmd as admin. delete old node_modules folder and run npm install again.
The Problem I faced (In Windows Computer)
When I was trying to install a couple of npm packages I got the following error:
npm - EPERM: operation not permitted - while npm was trying to rename a file
Here's my debug snippet for reference, if you've faced the similar problem:
After carefully checking out the answers from other users, I have created a detailed answer for the community
My Solution for the problem
Follow the mentioned steps
Right-click on the project folder
Go to properties -> Security Tab
Select Users -> Edit
In the Permission for Users section, Full control -> Give a check mark in Allow -> OK
Wait for Windows security to apply the new security rules
Click OK
Visualization of the steps
If you follow these steps and try to install npm packages again it will work properly.
Note: It's a best practice to close and open up the command line again to experience the changes
Simplest way
Hope I am not too late for this post but recently even I too got hit by this issue. And also I had no admin rights on my laptop.
Here is the simplest way I fixed the bug.
Locate the file name .npmrc (it will be in C:\Users\<user name>\.npmrc)
Open it and change the path of prefix= to prefix=C:\Users\<user name>\AppData\Roaming\npm
hope it will be helpful..
Happened to me since the folder/file was locked by another process. Used a tool (LockHunter) to terminate that process and it started working again (possible reason).
If you getting this error in an IDE's terminal/commands prompt, try delete node_modules, close IDE, and run the npm install command again.
The time when IDE started but still not completed its analysis of node_modules tree is a tricky moment, when packages installation may fail because IDE still scanning node_modules contents.
This error is caused by different problems try the below one of them will work for you!
try to run npm as Administrator
Run cmd as administrator npm config edit (You will get notepad editor)
Change Prefix variable to C:\Users\<User Name>\AppData\Roaming\npm
The errors went after I disabled my anti-virus (Avast)
Sometimes a simple cache clear like the below would fix it.
npm cache clear
For me the problem come from bash terminal. I change my terminal to powershell and it's ok.
Really easy to resolve
Find this command npm cache clean as a solution to those error in quick and simple way!
I updated my node version to 8.9.4 and ran the necessary install command again from administrator command prompt. It worked for me!
A reboot of my laptop and then
npm install
worked for me!
Running npm commands in Windows Powershell solved my issue.
Try npm i -g npm . NPM version 6.9 is work to me.
Apparently anti-virus software can also cause this error. In my case I had Windows Security's Ransomware Protection protecting my user folders which caused this error.
Windows 10,
Running the IDE (in my case IntelliJ) in administrator mode and executing npm install does resolves the problem.
If no IDE then run CMD in administrator mode and try executing npm install
For those trying to update config
If having trouble updating your npm config, try instead running using the -g flag. This solved the issue on Win 10 for me after trying everything else.
npm config edit -g
I am able to update the config and changes are reflected everywhere. This may be due to running npm in an organizational scope.
I was running create-react-app server. Simply stopped the server and everything worked just fine.
The simpler way to solve this by entering the below command
npm config set cache C:\tmp\nodejs\npm-cache --global
At least I just solved my problem in this way:
Search cmd
Then run as administrator
Then npm i -g expo-cli or npm config set prefix /usr/local
I just solved my problem.

Node.js says it can't load sqlite3 module, but does anyway

I'm working with the new Node.js Tools for Visual Studio and included the sqlite3 npm module. When I call require('sqlite3') it throws the error:
Error: Cannot find module './binding\Debug\node-v11-win32-ia32\node_sqlite3.node'
Odd thing is, when I ignore the error and continue running the code, everything works fine...until the function I'm in returns; then the server crashes.
Has anyone else had this issue? I have a suspicion that it has something to do with the ./binding part, but wouldn't know where to begin in terms of finding out why.
use this:-
npm install sqlite3 --build-from-source
This is what worked for me: https://www.npmjs.com/package/sqlite3
npm install https://github.com/mapbox/node-sqlite3/tarball/master
From: https://github.com/mapbox/node-sqlite3/wiki/Building-On-Windows
Install required software:
Python 2.x: https://www.python.org/downloads/release/python-2711/
Win SDK: http://www.microsoft.com/en-us/download/details.aspx?displayLang=en&id=8279
Microsoft Visual Studio 2010+: https://www.microsoft.com/es-es/download/details.aspx?id=48217
Build:
npm install sqlite
npm install
node-gyp configure build
I got the kind of problem, my node version is v10.16.3
This globally installed sqlite3 gives error in loading by require('sqlite3')
It been solved by install a sqlite3 local to project.
$ npm install sqlite3
Note without -g option, it works for me.
It seems this is a problem with the sqlite3 npm package itself. There exists a lib\binding\Release\ folder, but not a lib\binding\Debug\ folder. I just created a copy of the Release folder, named it Debug, and all is well.
In case this above has not worked for anyone, here is what worked for me:
sudo apt install node-sqlite3
(I am using Ubuntu with Vscode as editor). It seems installing this node-sqlite3 module was the one that was recognized.
To skip searching for pre-compiled binaries, and force a build from source, use
npm install --build-from-source

Categories

Resources