installing PhantomJS on Windows: rolling back Error: EPERM, unlink phantomjs.exe - node.js

I try to install karam/Jasmine/PhantomJS on my Windows machine.
It was installed before in a different project. I have my proxies set up nicely, but it throws a weird error.
npm ERR! error rolling back Error: EPERM, unlink 'C:\xampp\htdocs\acme\node_modules\karma-phantomjs-launcher\node_modules\phantomjs\lib\phantom\phantomjs.exe'
npm ERR! error rolling back karma-phantomjs-launcher#0.1.4 { [Error: EPERM, unlink 'C:\xampp\htdocs\acme\node_modules\karma-phantomjs-launcher\node_modules\phantomjs\lib\phantom\phantomjs.exe']
npm ERR! error rolling back errno: 50,
npm ERR! error rolling back code: 'EPERM',
npm ERR! error rolling back path: 'C:\\xampp\\htdocs\\acme\\node_modules\\karma-phantomjs-launcher\\node_modules\\phantomjs\\lib\\phantom\\phantomjs.exe' }
npm ERR! Error: EPERM, unlink 'C:\xampp\htdocs\acme\node_modules\karma-phantomjs-launcher\node_modules\phantomjs\lib\phantom\phantomjs.exe'
npm ERR! { [Error: EPERM, unlink 'C:\xampp\htdocs\acme\node_modules\karma-phantomjs-launcher\node_modules\phantomjs\lib\phantom\phantomjs.exe']
npm ERR! errno: 50,
npm ERR! code: 'EPERM',
npm ERR! path: 'C:\\xampp\\htdocs\\acme\\node_modules\\karma-phantomjs-launcher\\node_modules\\phantomjs\\lib\\phantom\\phantomjs.exe' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
So I deleted the phantomjs.exe and tried again.
I executed the console as admin and retried.
I deleted the whole node_modules folder and installed again
I used npm cache clear
I deactivated my A/V as suggested here
... same error.
Why would npm try to delete the PhantomJS during install? As I said, I deleted it before. So I have no node_modules folder, execute npm install and it creates the phantomjs.exe and then fails with said error.
Any ideas anyone?

I had a similar issue that ultimately seemed to have been caused by still having an errant phantomjs.exe process running while I was performing an npm update.
While it seems unlikely that this may have been the same cause as what you were experiencing, it seems to be at the very least one of the ways to receive this same error message.
I was able to resolve by opening up Windows Task Manager (Ctrl+Shift+Esc), finding phantomjs.exe in the Processes tab, and using 'End Process' on it.

Related

Trying to create a new react native project

I want to create a new react native project. At first, I faced a problem when I ran npm install -g expo-cli and I solved it by installing nvm, then installing node and npm by nvm. When I ran expo init NewProject, I got this error.
Could you help me solving it, please?
Uncaught Error [Error: EACCES: permission denied, open
'/home/pgf/.expo/state.json.1309825572'] {
errno: -13,
code: 'EACCES',
syscall: 'open',
path: '/home/pgf/.expo/state.json.1309825572'
}
I tried sudo expo init; I got this ✖ Something when wrong installing JavaScript dependencies. Check your npm logs. Continuing to initialize the app. and it created a project. Bur when I ran the project with expo start I got this error
Uncaught Error [Error: EACCES: permission denied, open '/home/pgf/.expo/state.json.2684774492'] {
errno: -13,
code: 'EACCES',
syscall: 'open',
path: '/home/pgf/.expo/state.json.2684774492'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # start: `expo start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /home/pgf/.npm/_logs/2020-05-29T19_37_07_602Z-debug.log
and this error when I ran it with sudo expo start
Cannot determine which native SDK version your project uses because the module `expo` is not installed. Please install it with `yarn add expo` and try again.
Could you help me solving this?
For me, there was no need to run it with sudo, since I ran into permissions errors. I had to reinstall expo-cli globally without using sudo. After that in your project directory:
sudo rm -rf ~/.expo
npm run start

npm install failed with Error: EPERM: operation not permitted, unlink '\node_modules'

I try to run "npm install" command in CMD ["node_modules" is inside C drive] but installation failing with below error.
OS :Windows 10.
Node JS version: 6.9.0.
Error: EPERM: operation not permitted, unlink.
Goal: To run AngularJs project.
CMD command
npm install -- no optional;
PS C:\Users\arunk\Work\Workspaces\workspace-2\brainbox-frontend-angular> npm install --no-optional
npm ERR! path C:\Users\arunk\Work\Workspaces\workspace-2\brainbox-frontend-angular\node_modules\.staging\typescript-5afdc8eb\lib\tsc.js
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\arunk\Work\Workspaces\workspace-2\brainbox-frontend-angular\node_modules\.staging\typescript-5afdc8eb\lib\tsc.js'
npm ERR! [Error: EPERM: operation not permitted, unlink 'C:\Users\arunk\Work\Workspaces\workspace-2\brainbox-frontend-angular\node_modules\.staging\typescript-5afdc8eb\lib\tsc.js']
{
npm ERR! stack: 'Error: EPERM: operation not permitted, unlink ' +
npm ERR! "'C:\\Users\\arunk\\Work\\Workspaces\\workspace-2\\brainbox-frontend-angular\\node_modules\\.staging\\typescript-5afdc8eb\\lib\\tsc.js'",
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'C:\\Users\\arunk\\Work\\Workspaces\\workspace-2\\brainbox-frontend-angular\\node_modules\\.staging\\typescript-5afdc8eb\\lib\\tsc.js'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
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 (though this is not recommended).
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\arunk\AppData\Roaming\npm-cache\_logs\2019-05-22T19_01_22_659Z-debug.log
I had the same problem and tried a lot of different things. This solved my problem:
1 - Uninstall NodeJs
2 - Delete folders 'npm' and 'npm-cache' from AppData/Roaming
3 - Deactivate firewall and all antivirus (including Windows Defender)
4 - Reboot the system
5 - Open command prompt as administrator and execute 'npm install'
Like you I have wasted much time trying to get 'npm install' to install Angular projects from its 'project.json' file and received similar error messages that are unhelpful; Recently I installed 'yarn' and this does a much better job of populating the 'node_modules' folder and it also generates more useful error and warning messages in the process.
Try the following steps:
Install 'Yarn' - go to it's website and download the installer for your operating system.
Got to your project directory (the one containing 'project.json')
enter the command 'yarn' and wait. This will perform the same function
as 'npm install', however it will generate fewer messages but the ones
it does will be more pertinent.
I hope this helps.
I was using yarn to install axios and got the same error, but I figured out that this error is not peculiar to axios since the same thing happens with all other packages.
Killing all running node process worked for me.
Perhaps a problem with the file system.
Check your C drive with the windows verification tool (right click on the C: -> Properties -> Tools -> Check). Repair the errors if it's needed.
It worked for me. I write here this solution for people (like me) with similar issue.
Similar problem can also happen if you try to uninstall a dependency while in another terminal window you're using
ng serve
Simply stop that operation and only then you can uninstall it.
Please try following steps:
check your antivirus status is enable or disable
disable your antivirus during the installation.
I hope this helps. It worked for me.

Unable to install angular cli with npm errno -4048 package.json

I tried installing angular cli with npm. But I'm getting the below error while executing the command npm install -g #angular/cli.
I am not executing this command as admin, but as a user.
D:\AngularWorkstation>npm install -g #angular/cli
npm WARN sass-loader#6.0.6 requires a peer of node-sass#^4.0.0 but none is installed. You must install peer dependencies yourself.
npm ERR! path **D:\node_modules\node_modules\#angular\cli\node_modules\which\package.json.365294863
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename
npm ERR! Error: EPERM: operation not permitted, rename 'D:\node_modules\node_modules\#angular\cli\node_modules\which\package.json.365294863' -> 'D:\node_modules\node_modules\#angular\cli\node_modules\which\package.json'
npm ERR! { Error: EPERM: operation not permitted, rename 'D:\node_modules\node_modules\#angular\cli\node_modules\which\package.json.365294863' -> 'D:\node_modules\node_modules\#angular\cli\node_modules\which\package.json'
npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, rename 'D:\node_modules\node_modules\#angular\cli\node_modules\which\package.json.365294863' ->** 'D:\node_modules\node_modules\#angular\cli\node_modules\which\package.json'
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'rename',
npm ERR! path: 'D:\\node_modules\\node_modules\\#angular\\cli\\node_modules\\which\\package.json.365294863',
npm ERR! dest: 'D:\\node_modules\\node_modules\\#angular\\cli\\node_modules\\which\\package.json' },
npm ERR! stack: 'Error: EPERM: operation not permitted, rename \'D:\\node_modules\\node_modules\\#angular\\cli\\node_modules\\which\\package.json.365294863\' -> \'D:\\node_modules\\node_modules\\#angular\\cli\\node_modules\\which\\package.json\'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'rename',
npm ERR! path: 'D:\\node_modules\\node_modules\\#angular\\cli\\node_modules\\which\\package.json.365294863',
npm ERR! dest: 'D:\\node_modules\\node_modules\\#angular\\cli\\node_modules\\which\\package.json',
npm ERR! parent: '#angular/cli' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\techno\AppData\Roaming\npm-cache\_logs\2018-01-03T09_14_35_602Z-debug.log
*PS : I'm using Windows10 OS. I also tried changing the npm global path to'D:\node_modules' to check if it's due to permission issue. However the output is the same.
node --version : v7.7.2
npm --version : 4.1.2*
I had a similar issue when trying to install Yeoman with npm on Windows 10. The culprit turned out to be the McAfee AV software that was installed on my machine.
McAfee seemed to be scanning the changes that npm was trying to make to a json file and as part of the scanning routine, prevented the rename from occurring. This resulted in a 4048 error being raised by npm similar to the error in your output.
To get around this I:
Uninstalled McAfee and restarted my machine so that it reverted to Microsoft's built-in security software.
Re-ran the npm install command and it worked correctly.
Alternatively, you could change the settings of your AV software to not actively check file changes for the node_modules folder. This would hopefully allow your AV software to stay installed and the npm command to work too.
From your error logs, It seems that there is some permission issue while installing the packages. You can specifically resolve this issue by two ways.
1) If you are trying to install the packages globally then you have to run the npm install <pkg_name> -g command with the administrative user or using sudo npm install <pkg_name> -g command.
To install the npm-packages globally you can follow the steps below:
Run the command prompt as the administrative user.
Run npm install <pkg_name> -g.
2) You should try going to the top-level folder in Windows Explorer, right-click on "get more info" option then go down to the permissions section, give yourself all permissions, and tell it to apply them recursively.
Or simply you can go to specified npm working directory and edit to permission section and allow all the permission to the current user and also change the owner to itself for all the recursive directories as well.
Then boot up Windows again.
Note: If you are installing an npm-package locally, then you should be in your local project directory and can try running sudo npm install <pkg-name> command to install required package. the purpose of using sudo is that it will change your owner permissions so you can make your current user authorized to run npm commands.
I'd recommend you to take a look at https://docs.npmjs.com/getting-started/fixing-npm-permissions
1) uninstall node
2) download latest version of node from [https://nodejs.org/en/][1] .
3) install node js

NPM is deleting old packages

Whenever I try to install a new package to my project, npm randomly deletes an old package that I have and then throws this error:
npm ERR! Error: EPERM: operation not permitted, rename 'C:\wamp\www\react_projects\Nasss\node_modules\axios' -> 'C:\wamp\www\react_projects\Nasss\node_modules\.axios.DE
LETE'
npm ERR! at moveAway (C:\Program Files\nodejs\node_modules\npm\lib\install\action\finalize.js:38:5)
npm ERR! at destStatted (C:\Program Files\nodejs\node_modules\npm\lib\install\action\finalize.js:27:7)
npm ERR! at FSReqWrap.oncomplete (fs.js:82:15)
npm ERR!
npm ERR! Error: EPERM: operation not permitted, rename 'C:\wamp\www\react_projects\Nasss\node_modules\axios' -> 'C:\wamp\www\react_projects\Nasss\node_modules\.axios.DE
LETE'
npm ERR! at Error (native)
npm ERR! { [Error: EPERM: operation not permitted, rename 'C:\wamp\www\react_projects\Nasss\node_modules\axios' -> 'C:\wamp\www\react_projects\Nasss\node_modules\.axio
s.DELETE'] parent: 'Nasss' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! C:\wamp\www\react_projects\Nasss\npm-debug.log
Is it facing some kind of conflict with the old packages that I have installed?
P.S: I already have the CMD running as admin.
This seems like a problem with weird permissions.
It looks like npm is unable to rename the directories to other names which maybe are the old versions of the modules kept for backups if the new versions fail to get installed.
Are you sure you have the same permissions in "Program Files\nodejs\node_modules" and all of its subdirectories? It look like you may hev different permissions for existing subdirectories than you have for new subdirectories and/or the parent node_modules.
On Unix/Linux I would fix it with chmod and chown in one line but for Windows you will have to dive through the directories and examine the permissions.
O maybe you need to run as admin to update/install modules globally. It depends on your permissions and your configuration.

Deploying Ghost 0.4.2 to Azure Site using Git Deploy

I'm trying to upgrade my really simply ghost test site to the latest version of Ghost 0.4.2. I've followed the upgrade instructions on their website and am able to run the upgraded version of the project locally.
When I try to push the upgrade version to my azure instance using the GIT Deploy process I'm getting the following error log. Can anyone shed some light on what's going wrong. My best guess is that their is something wrong with the new version of sqlite.
Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling node.js deployment.
KuduSync.NET from: 'D:\home\site\repository' to: 'D:\home\site\wwwroot'
Copying file: 'iisnode.yml'
Copying file: 'package.json'
Node.js versions available on the platform are: 0.6.17, 0.6.20, 0.8.2, 0.8.19, 0.8.26, 0.10.5, 0.10.18, 0.10.21, 0.10.24, 0.10.26, 0.10.28.
Selected node.js version 0.10.28. Use package.json file to choose a different version.
Updating iisnode.yml at D:\home\site\wwwroot\iisnode.yml
npm http GET https://registry.npmjs.org/sqlite3
npm http 304 https://registry.npmjs.org/sqlite3
npm ERR! error rolling back Error: EPERM, unlink 'D:\home\site\wwwroot\node_modules\sqlite3\lib\binding\Release\node-v11-win32-ia32\node_sqlite3.node'
Failed exitCode=50, command="D:\Program Files (x86)\nodejs\0.10.28\node.exe" "D:\Program Files (x86)\npm\1.4.9\node_modules\npm\bin\npm-cli.js" install --production
npm ERR! error rolling back sqlite3#2.2.0 { [Error: EPERM, unlink 'D:\home\site\wwwroot\node_modules\sqlite3\lib\binding\Release\node-v11-win32-ia32\node_sqlite3.node']
An error has occurred during web site deployment.
npm ERR! error rolling back errno: 50,
npm ERR! error rolling back code: 'EPERM',
npm ERR! error rolling back path: 'D:\\home\\site\\wwwroot\\node_modules\\sqlite3\\lib\\binding\\Release\\node-v11-win32-ia32\\node_sqlite3.node' }
npm ERR! Error: EPERM, unlink 'D:\home\site\wwwroot\node_modules\sqlite3\lib\binding\Release\node-v11-win32-ia32\node_sqlite3.node'
npm ERR! { [Error: EPERM, unlink 'D:\home\site\wwwroot\node_modules\sqlite3\lib\binding\Release\node-v11-win32-ia32\node_sqlite3.node']
npm ERR! errno: 50,
npm ERR! code: 'EPERM',
npm ERR! path: 'D:\\home\\site\\wwwroot\\node_modules\\sqlite3\\lib\\binding\\Release\\node-v11-win32-ia32\\node_sqlite3.node' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "D:\\Program Files (x86)\\nodejs\\0.10.28\\node.exe" "D:\\Program Files (x86)\\npm\\1.4.9\\node_modules\\npm\\bin\\npm-cli.js" "install" "--production"
npm ERR! cwd D:\home\site\wwwroot
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! path D:\home\site\wwwroot\node_modules\sqlite3\lib\binding\Release\node-v11-win32-ia32\node_sqlite3.node
npm ERR! code EPERM
npm ERR! errno 50
npm ERR! stack Error: EPERM, unlink 'D:\home\site\wwwroot\node_modules\sqlite3\lib\binding\Release\node-v11-win32-ia32\node_sqlite3.node'
I think this is related to the file in question ...\node_sqlite3.node being locked. When faced with the same error I've restarted Azure Website and redeployed, it worked the second time.
I know, not exactly a root cause solution, but will get you up and running if you're stuck.
I had the same problem. I found that my Git repo had the node_modules folder included so this was being deployed along with the code. This isn't needed - Kudu will build the dependencies at deploy time.
Try removing the node_modules folder from your repo, and stick an entry in your .gitignore so that it doesn't get re-added. You'll also want to do the same for your Ghost.db and any other bits of content that shouldn't get replaced at deploy time.

Resources