Error: npm ERR! write after end - javascript

I am having issues installing Cordova and Ionic.
At first I couldn't because of what seems to be a corrupted installation, that led me to uninstall NodeJS - Cordova - Ionic.
Now, I've reinstalled NodeJS, without issues but when it comes to the famous line :
npm install -g cordova ionic, I've got this error :
npm ERR! write after end
then everytime I try to install cordova ionic, I've got the same error for a different package ... Here are errors I get :
C:\Windows\System32>npm install -g cordova ionic
npm ERR! write after end
npm ERR! A complete log of this run can be found in:
npm ERR! d:\Profiles\cjolliet\AppData\Roaming\npm-cache\_logs\2018-03-07T09_31_22_439Z-debug.log
C:\Windows\System32>npm install -g cordova ionic
npm ERR! code ETARGET
npm ERR! notarget No matching version found for ansi-styles#^3.2.1
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'chalk'
npm ERR! notarget
npm ERR! A complete log of this run can be found in:
npm ERR! d:\Profiles\cjolliet\AppData\Roaming\npm-cache\_logs\2018-03-07T09_40_04_399Z-debug.log
C:\Windows\System32>
C:\Windows\System32>npm install -g cordova ionic
npm ERR! code ETARGET
npm ERR! notarget No matching version found for supports-color#^5.3.0
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'chalk'
npm ERR! notarget
npm ERR! A complete log of this run can be found in:
npm ERR! d:\Profiles\cjolliet\AppData\Roaming\npm-cache\_logs\2018-03-07T09_44_05_319Z-debug.log
If any of you can help me, it would be very appreciate ;-) Have a nice day...
EDIT 1 : after installing some packages and trying again, I've got this now :
npm install -g cordova ionic
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\path-is-absolute-86a430cb\package.json'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\parseurl-f42ab09d\package.json'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\path-is-absolute-86a430cb\index.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\opn-07c4c2dd\package.json'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\os-tmpdir-c1eaefc0\package.json'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\parse-glob-106d32b7\package.json'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\parseurl-f42ab09d\README.md'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\path-is-absolute-86a430cb\license'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\opn-07c4c2dd\index.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\os-tmpdir-c1eaefc0\index.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\parse-glob-106d32b7\README.md'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\parseurl-f42ab09d\LICENSE'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\superagent-4d7c9590\lib\agent-base.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\path-is-absolute-86a430cb\readme.md'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\os-tmpdir-c1eaefc0\license'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\opn-07c4c2dd\license'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\parse-glob-106d32b7\LICENSE'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\parseurl-f42ab09d\index.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\superagent-4d7c9590\lib\client.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\opn-07c4c2dd\readme.md'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\os-tmpdir-c1eaefc0\readme.md'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\parse-glob-106d32b7\index.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\parseurl-f42ab09d\HISTORY.md'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\opn-07c4c2dd\xdg-open'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\inquirer-b71d51ab\lib\utils\events.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\inquirer-b71d51ab\lib\utils\paginator.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\inquirer-b71d51ab\lib\utils\readline.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\inquirer-b71d51ab\lib\utils\screen-manager.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\readdirp-34d428ea\test\bed\root_dir2\root_dir2_file1.ext1'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\inquirer-b71d51ab\lib\utils\utils.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\readdirp-34d428ea\test\bed\root_dir2\root_dir2_file2.ext2'
npm WARN tar ENOENT: no such file or directory, lstat 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\cordova-lib-a64e9936\src\cordova\metadata'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\qs-095a6ca4\lib\formats.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\qs-095a6ca4\lib\index.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\qs-095a6ca4\lib\parse.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\qs-095a6ca4\lib\stringify.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\qs-095a6ca4\lib\utils.js'
npm WARN tar ENOENT: no such file or directory, lstat 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\cordova-app-hello-world-60bb7e30\template_src\res\icon\blackberry10'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\tiny-lr-cf15ff1c\src\client.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\tiny-lr-cf15ff1c\src\index.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\tiny-lr-cf15ff1c\src\server.js'
npm ERR! code EINTEGRITY
npm ERR! Verification failed while extracting readable-stream#^2.0.5:
npm ERR! sha512-vuYxeWYM+fde14+rajzqgeohAI7YoJcHE7kXDAc4Nk0EbuKnJfqtY9YtRkLo/tqkuF7MsBQRhPnPeyjYITp3ZQ== integrity checksum failed when using sha512: wanted sha512-vuYxeWYM+fde14+rajzqgeohAI7YoJcHE7kXDAc4Nk0EbuKnJfqtY9YtRkLo/tqkuF7MsBQRhPnPeyjYITp3ZQ== but got sha512-tK0yDhrkygt/knjowCUiWP9YdV7c5R+8cR0r/kt9ZhBU906Fs6RpQJCEilamRJj1Nx2rWI6LkW9gKqjTkshhEw==. (25689 bytes)

Try installing latest npm version this happens a lot with ionic.
npm install -g npm#latest
npm cache verify
npm i
If this doesn't work I advise you to switch to yarn. It's faster & easier to use. This is the link to download YARN.
After installing just run this command yarn global add cordova ionic
Ionic CLI uses npm by default. So go to your project & run $ yarn install.
If you want Ionic to use yarn by default run this: $ ionic config set -g yarn true

In my case, I didn't downgrade my npm because it will cause chaos in other dependencies. Instead, I tried running
npm cache verify
Error gone...

Let, update the latest version of npm for running this command,
npm install npm#latest -g
Then run this command,
npm install -g cordova ionic

It happened to me when I tried to install a ionic3 project with npm#5.8, well I solved this issue just add some params, use the following:
npm i --unsafe-perm
and it works.

This still happens randomly on some npm versions. Issue got resolved on downgrading to npm version 5.6.0 using command
npm install -g npm#5.6.0
Hope that will help someone.

Update July 28, 2018
This problem is related to npm version 5.7.1
Upgrading to node version 8.11.3 with npm version 5.8.0 solve the problem

i faced the same issue. For my case, i update npm to latest 6.1.0 by running "npm install -g npm#latest". Then run "npm cache verify

Just run
npm cache verify
This will clean it all.

Usually this error is due to your Antivirus blocking access to changing the files, to solve this:
1- You can try to turn your Antivirus off (temporarily) & try the installation again
2- If that alone doesn't work, try using the --force option while installing
I had this issue with some packages & it was solved by using one of the 2 steps above.
For example:
npm install -g cordova ionic --force

None of the previous answers could help me.
Fortunately, after a lot of 'try and error', I found the following simple solution:
delete (or move) the file 'package-lock.json' and npm install works
flawlessly.
Tip: if you have your project in a git repository:
add the file 'package-lock.json' in '.gitignore'

Related

npm start throwing error 'This is related to npm not being able to find a file.'

I just created a react app, it was working fine but once I restart the editor it is throwing error like this :
Poojas-MacBook-Air:newreact pooja$ npm start
npm ERR! path /Users/pooja/Desktop/projects/newreact/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open
'/Users/pooja/Desktop/projects/newreact/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/pooja/.npm/_logs/2020-11-28T10_27_42_118Z-debug.log
Please help if anyone knows about it.
Make sure you have the latest npm (npm install -g npm).
Add an exception to your antivirus to ignore the node_modules folder in your project.
rm -rf node_modules package-lock.json
npm install
Sometimes the PATH is not correct, just open the cmd and cd to the address where the package.json is and then run npm start
For me, it was because of the running Metro server. If anyone is experiencing this issue in react-native, make sure you have stopped the running Metro server instance before entering npm i <package-name>.
With yarn, I think, there's no such issue.
To resolve package.json file, go to your project folder and find package.json location folder.
Open terminal and make sure your are in correct path where package.json file located.
eg: c://projectfolder/folder1/clientapp> npm start

'npm install -g' cannot find 'Roaming\npm\node_modules\' directory

I've just downloaded and installed nodejs to my new machine but neither 'npm install -g' nor 'npm install' command works. It gives ENOENT error. I check the path that gloabally installed packages, namely 'C:\Users\USER\AppData\Roaming\npm\node_modules' folder, and the error says it could not find 'lib' or 'bin' folder but all the folders created by command missing the first letter. The npm error I get down below is shown when try to install typescript globally. I couldn't seem to find a solution, does anyone have any idea what should I do? Thanks in advance.
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\USER\AppData\Roaming\npm\node_modules\.staging\typescript-21dd751b\bin\tsc'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\USER\AppData\Roaming\npm\node_modules\.staging\typescript-21dd751b\bin\tsserver'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\USER\AppData\Roaming\npm\node_modules\.staging\typescript-21dd751b\lib\cancellationToken.js'
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\USER\AppData\Roaming\npm\node_modules\.staging\typescript-21dd751b\lib\cs\diagnosticMessages.generated.json'
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://npm.community>
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\USER\AppData\Roaming\npm-cache\_logs\2019-11-12T12_33_04_656Z-debug.log
See folders' screenshot

How do I fix the npm install on Linux?

I'm trying to use npm install to install a package but I keep getting below error.
I tried updating and downloading again from root but nothing seems to work.
hackathonday1-2 git:(save-button) ✗ npm install file-saver --save
npm WARN checkPermissions Missing write access to
/home/salman/node_modules/axios npm WARN checkPermissions Missing
write access to /home/salman/node_modules/coffeescript npm WARN
checkPermissions Missing write access to
/home/salman/node_modules/coffee-script npm WARN checkPermissions
Missing write access to /home/salman/node_modules/file-saver npm WARN
checkPermissions Missing write access to
/home/salman/node_modules/materialize-css npm WARN enoent ENOENT: no
such file or directory, open '/home/salman/package.json' npm WARN
salman No description npm WARN salman No repository field. npm WARN
salman No README data npm WARN salman No license field.
npm ERR! code EACCES npm ERR! syscall access npm ERR! path
/home/salman/node_modules/axios npm ERR! errno -13 npm ERR! Error:
EACCES: permission denied, access '/home/salman/node_modules/axios'
npm ERR! [Error: EACCES: permission denied, access
'/home/salman/node_modules/axios'] { npm ERR! stack: "Error: EACCES:
permission denied, access '/home/salman/node_modules/axios'", npm ERR!
errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'access',
npm ERR! path: '/home/salman/node_modules/axios' npm ERR! } npm ERR!
npm ERR! The operation was rejected by your operating system. npm ERR!
It is likely you do not have the permissions to access this file as
the current user npm ERR! npm ERR! If you believe this might be a
permissions issue, please double-check the npm ERR! permissions of the
file and its containing directories, or try running npm ERR! the
command again as root/Administrator.
npm ERR! A complete log of this run can be found in: npm ERR!
/home/salman/.npm/_logs/2019-09-24T03_37_30_909Z-debug.log
If there is a permission error on Linux for npm install, you can try to include sudo at the beginning of command. sudo npm install. Also make sure node.js is installed globally on your machine. Also make sure you have a package.json folder.
It's simply complaining about the fact that you don't own the folders /home/salman/node_modules/axios, /home/salman/node_modules/file-saver etc. Since it is your home directory, there really shouldn't be any directory or files that you don't own in /home/salman. My guess is that this happened because you ran npm with sudo causing it to create some files in your home folder that is owned by root instead of salman.
To fix the permission issue simply retake ownership of the node_modules folder:
cd /home/salman
sudo chown -R salman:salman node_modules
The -R flag makes chown recursively set you as the owner to all files and subfolders in the directory.
Side note: you really shouldn't use your home directory as your npm project directory. Do npm install in individual project directories. Yes, this wastes disk space but disk space is cheap and can freely be wasted. Even if you have 10 node.js projects you are unlikely to use more than 5GB of disk space even though there are lots of duplicate code files. A single HD movie is sometimes larger than that. Typical disk space usage for code is around 2GB.
sudo chown -R $USER /home/salman/node_modules
This command is useful.. Run it on your system..

How do i Solve the following error while runnin npm install mysqljs/mysql?

I wanted to install the Mysql into my node.js project. I tried to install it using these commands
npm install mysqljs/mysql
npm install mysql
but I got the following error
npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\cbshr\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\cbshr\package.json'
npm WARN cbshr No description
npm WARN cbshr No repository field.
npm WARN cbshr No README data
npm WARN cbshr No license field.
npm install mysqljs/mysql
npm install mysql
npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\cbshr\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\cbshr\package.json'
npm WARN cbshr No description
npm WARN cbshr No repository field.
npm WARN cbshr No README data
npm WARN cbshr No license field.
You need to run your terminal from the folder that contains your project. Based on the message, the terminal is running from C:\Users\cbshr\.
In Windows, shift-rightclick in the folder and choose "Open Command Window Here' or use the cd command to navigate to the folder containing your project.

why there are errors when i install solc compiler with npm?

with the latest version of npm but i cant install compiler successfully.
ash#ubuntu:~/inbox$ node -v
v8.11.1
ash#ubuntu:~/inbox$ npm -v
5.8.0
ash#ubuntu:~/inbox$ sudo npm install --save solc
npm WARN saveError ENOENT: no such file or directory, open '/home/ash/inbox/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/home/ash/inbox/package.json'
npm WARN webpack-cli#2.0.14 requires a peer of webpack#^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN inbox No description
npm WARN inbox No repository field.
npm WARN inbox No README data
npm WARN inbox No license field.
+ solc#0.4.21
updated 1 package in 5.593s
ash#ubuntu:~/inbox$
enter image description here
You're attempting to install into a project directory which will try to update the project's package.json file to add the dependency. The install still worked. You will find it under node_modules/solc.
The better approach is to install it globally:
npm install -g solc

Categories

Resources