npm ERR! Error: EPERM: operation not permitted, unlink - javascript

OS : Windows 10.
npm version : 6.9.0
node version : 12.4.0
I'm working on an expo application.
I would like to install all the packages on my expo application (npm install). But, an error occured :
17254 error [OperationalError: EPERM: operation not permitted, unlink ...
I have seen this error on many subjects, but no one answer to my problem.
I've already tried to :
Launch my terminal as an administrator.
npm config set safe-perm=true.
npm install --no-bin-links
npm cache clear --force
An exemple of error message that I have :
17254 error cause: [Error: EPERM: operation not permitted, unlink 'C:\Users\Thomas\Desktop\someDirectory\someDirectory\someDirectory\someDirectory\node_modules\.staging\react-native-99ed309f\Libraries\Renderer\oss\ReactFabric-dev.js'] {
17254 error errno: -4048,
17254 error code: 'EPERM',
17254 error syscall: 'unlink',
17254 error path: 'C:\\Users\\Thomas\\Desktop\\someDirectory\\someDirectory\\someDirectory\\someDirectory\\node_modules\\.staging\\react-native-99ed309f\\Libraries\\Renderer\\oss\\ReactFabric-dev.js'
17254 error },
17254 error stack: 'Error: EPERM: operation not permitted, unlink ' +
17254 error "'C:\\Users\\Thomas\\Desktop\\someDirectory\\someDirectory\\someDirectory\\someDirectory\\node_modules\\.staging\\react-native-99ed309f\\Libraries\\Renderer\\oss\\ReactFabric-dev.js'",
17254 error errno: -4048,
17254 error code: 'EPERM',
17254 error syscall: 'unlink',
17254 error path: 'C:\\Users\\Thomas\\Desktop\\someDirectory\\someDirectory\\someDirectory\\someDirectory\\node_modules\\.staging\\react-native-99ed309f\\Libraries\\Renderer\\oss\\ReactFabric-dev.js'
17254 error }
17255 error The operation was rejected by your operating system.
17255 error It's possible that the file was already in use (by a text editor or antivirus),
17255 error or that you lack permissions to access it.
17255 error
17255 error If you believe this might be a permissions issue, please double-check the
17255 error permissions of the file and its containing directories, or try running
17255 error the command again as root/Administrator (though this is not recommended).
17256 verbose exit [ -4048, true ] ```

Is there a another instance of node running, that is also using ReactFabric-dev.js? If so, terminate and retry. Also try to move your project to a folder "closer" to root. Windows sometimes gets confused with very long paths.

Solved it by logging into npmjs:
npm login
or
uninstall all npm modules and re-install with npm install --no-bin-links
or
rd /s /q C:\Users\foo\AppData\Roaming\npm-cache
rd /s /q C:\Users\foo\AppData\Roaming\npm

I had this error message, to solve it you have to:
1) add your project folder in Windows Defender exclusions list.
2) remove your node_modules folder
3) run:
npm install

What I did is:
Deleted node_modules folder;
Opened VSCode as administrator;
Ran the following commands in terminal:
npm cache clean --force
npm install

Try installing it globally first, using the command
npm install -g create-react-app
And then, you can create your app using the command,
npx create-react-app <Name_of_your_app>

Related

How to resolve EPERM: operation not permitted error in webpack command?

How to resolve EPERM: operation not permitted error in webpack command?
The following error message occurs when using webpack.
PS C:\Workspace\Mission> npm run dev
> webpack-demo#1.0.0 dev
> webpack --mode=development
[webpack-cli] [Error: EPERM: operation not permitted, open 'C:\Workspace\Mission\dist\px.bundle.js'] {
errno: -4048,
code: 'EPERM',
syscall: 'open',
path: 'C:\\Workspace\\Mission\\dist\\px.bundle.js'
}
Running the npm cache clean --force command works fine.
However, if I run the npm run dev command 3 or 4 times, the same error repeats again.
I gave the account admin rights, and I also gave full control to the folder. I tried running it in admin mode, but it didn't work.
How to fix this error?

Getting Error after installing react native firebase storage

So I was working with my React Native application and had to install react-native firebase storage for image storing. So I ran npm install #react-native-firebase/storage after installing it I re-run my server and after that, I am getting this error. I don't know why I am getting this error. Kindly help me out.
Getting this error:
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
F:\Salvador\node_modules\#react-native-firebase\storage\android\src\main\java\io\invertase\firebase\storage\ReactNativeFirebaseStorageModule.java:234: error: cannot find symbol
firebaseStorage.useEmulator(host, port);
^
symbol: method useEmulator(String,int)
location: variable firebaseStorage of type FirebaseStorage
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-firebase_storage:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 12s
at makeError (F:\Salvador\node_modules\execa\index.js:174:9)
at F:\Salvador\node_modules\execa\index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async runOnAllDevices (F:\Salvador\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
at async Command.handleAction (F:\Salvador\node_modules\react-native\node_modules\#react-native-community\cli\build\index.js:186:9)
info Run CLI with --verbose flag for more details.
When I run my server I get this error
info Run CLI with --verbose flag for more details.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Salvador#0.0.1 android: `react-native run-android`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Salvador#0.0.1 android script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Home\AppData\Roaming\npm-cache\_logs\2021-06-02T14_16_46_571Z-debug.log
If anyone else is getting this error what you need to do is open your react native android folder in Android Studio and then build and run your application via Android Studio. It will successfully run the project after that close Android Studio and now again start your react native project.
Now you will get 0 errors.
Also, run npm outdated after running that try upgrading your outdated packages also as my storage version was 12.0 but auth and app of firebase was 11.2.

Installing phantomjs using npm error

I'm doing a unit testing for my javascript codes. I prefer to use a headless browser for easier running. It goes well when I installed some dependencies but when I install phantomjs, it has an error.
C:\Phantomjs>npm install -g phantomjs npm WARN deprecated
phantomjs#2.1.7: Package renamed to phantomjs-prebuilt. Plea se update
'phantomjs' package references to 'phantomjs-prebuilt' npm WARN
deprecated node-uuid#1.4.8: Use uuid module instead npm WARN
deprecated tough-cookie#2.2.2: ReDoS vulnerability parsing Set-Cookie
h ttps://nodesecurity.io/advisories/130
C:\Users.ra\AppData\Roaming\npm\phantomjs ->
C:\Users.ra\AppDa
ta\Roaming\npm\node_modules\phantomjs\bin\phantomjs
phantomjs#2.1.7 install C:\Users.ra\AppData\Roaming\npm\node_modules\ phantomjs
node install.js
Considering PhantomJS found at
C:\Users.ra\AppData\Roaming\npm\phantomj s.CMD Looks like an
npm install -g on windows; skipping installed version. Downloading
https://github.com/Medium/phantomjs/releases/download/v2.1.1//phanto
mjs-2.1.1-windows.zip Saving to
C:\Users.ra\AppData\Local\Temp\phantomjs\phantomjs-2.1.1-wind
ows.zip Using proxy http://.ra:******#proxy:3128/ Receiving...
Error making request. Error: tunneling socket could not be
established, statusCode=502
at ClientRequest.onConnect (C:\Users.ra\AppData\Roaming\npm\node_mo
dules\phantomjs\node_modules\tunnel-agent\index.js:165:19)
at Object.onceWrapper (events.js:320:30)
at emitThree (events.js:135:13)
at ClientRequest.emit (events.js:216:7)
at Socket.socketOnData (_http_client.js:470:11)
at emitOne (events.js:115:13)
at Socket.emit (events.js:210:7)
at addChunk (_stream_readable.js:264:12)
at readableAddChunk (_stream_readable.js:251:11)
at Socket.Readable.push (_stream_readable.js:209:10)
Please report this full log at https://github.com/Medium/phantomjs npm
WARN Error: EPERM: operation not permitted, scandir
'C:\Users.ra\Ap
pData\Roaming\npm\node_modules\phantomjs\node_modules\dashdash\node_modules'
npm WARN { Error: EPERM: operation not permitted, scandir
'C:\Users.ra
\AppData\Roaming\npm\node_modules\phantomjs\node_modules\dashdash\node_modules'
npm WARN stack: 'Error: EPERM: operation not permitted, scandir
\'C:\Users\p
ardillo.ra\AppData\Roaming\npm\node_modules\phantomjs\node_modules\dashda
sh\node_modules\'', npm WARN errno: -4048, npm WARN code:
'EPERM', npm WARN syscall: 'scandir', npm WARN path:
'C:\Users\.ra\AppData\Roaming\npm\node_modules\p
hantomjs\node_modules\dashdash\node_modules' } npm ERR! code
ELIFECYCLE npm ERR! errno 1 npm ERR! phantomjs#2.1.7 install: node
install.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the
phantomjs#2.1.7 install script. npm ERR! This is probably not a
problem with npm. There is likely additional log ging output above.`
What should I do?
The simplest installation method is
Install NodeJS
Using Node's package manager install phantomjs: npm -g install phantomjs-prebuilt
After installation, you may use phantom as simple as:
driver = webdriver.PhantomJS() # or add to your PATH
driver.set_window_size(1024, 768) # optional
driver.get('https://google.com/')
driver.save_screenshot('screen.png') # save a screenshot to disk
sbtn = driver.find_element_by_css_selector('button.gbqfba')
sbtn.click()
If your system path environment variable isn't set correctly, you'll need to specify the exact path as an argument to webdriver.PhantomJS(). Replace this:
driver = webdriver.PhantomJS() # or add to your PATH
... with the following:
driver = webdriver.PhantomJS(executable_path='/usr/local/lib/node_modules/phantomjs/lib/phantom/bin/phantomjs')
References:
How do I set a proxy for phantomjs/ghostdriver in python webdriver?
https://dzone.com/articles/python-testing-phantomjs
Try run npm install phantomjs-prebuilt
phantomjs name changed to phantomjs-prebuilt on Pre-2.0 version release.
Source: view this link for detailed description of the name change.

Creating a new angular project with ng new

When I try to create a new Angular 4 project with 'ng new myProject', the project folder, sub folders and files are created,
but I also always get these errors:
npm ERR! path c:\projects\hello-world\node_modules\fsevents\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rmdir
npm ERR! Error: EPERM: operation not permitted, rmdir 'c:\projects\hello-world\node_modules\fsevents\node_modules'
npm ERR! { Error: EPERM: operation not permitted, rmdir 'c:\projects\hello-world\node_modules\fsevents\node_modules'
npm ERR! stack: 'Error: EPERM: operation not permitted, rmdir \'c:\\projects\\hello-world\\node_modules\\fsevents\\node_modules\'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'rmdir',
npm ERR! path: 'c:\\projects\\hello-world\\node_modules\\fsevents\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
I open the Node.js command prompt as Administrator when I issue the ng new command.
I am using Win7 Pro. I have install the following successfully and without any errors. The ng -v returns the following:
-Angular CLI: 1.5.0
-Node: 8.9.0
-OS: win32 x64
-Angular:
npm -v returns: 5.5.1
I give my user account, based on the 'whoami' results, full admin permissions to the myProject folder, the C:\Users\myAccount\AppData\Roaming\npm folder and %APPDATA%\npm-cache folder.
I also perform a 'npm cache verify'.
But I still get the above errors on the ng new command.
How do I correct these errors? Or can I ignore these errors?
If you still run into this problem, one reason you might be running into this is that you installed your CLI tools (#angular/cli) using either 'sudo npm install -g #angular/cli' or as root, from the 'sudo su - root' command, then simply 'npm install -g #angular/cli', and your problem seems to arise whenever you're not logged in and calling an 'ng' command as root or with 'sudo'. This makes sense, but it always causes some kind of insufficient permission related error; and it's not even your fault.
You can easily try to fix or mitigate this serious error by creating and saving a dot-file named '.npm-global' in your home directory ('~/'), then running the command, npm config set prefix '~/.npm-global'.
Then, simply include the line in either /etc/profile or ~/.profile, export PATH=~/.npm-global/bin:$PATH, and run 'source /etc/profile' or 'source ~/.profile' to finalize it. [1]
After that, simply remove anything Node, like 'node_modules/', 'package-lock.json', just all of it.... Then, try installing your NPM packages again -- this time, without using 'sudo' and without root signed in.
https://docs.npmjs.com/getting-started/fixing-npm-permissions

Protractor in STS IDE -> Could not find update-config.json

Currently I have Protractor v.5.1.1, Node.js v.6.10.0
All protractor tests work in window console but when I try to run them from STS IDE I get below error. Of course i did 'webdriver-manager update' but it doesn't help at all. Does anyone has an idea how to resolve this problem?
Below the error respectively when I use or do not 'directConnect'
[22:21:48] I/launcher - Running 1 instances of WebDriver
[22:21:48] I/direct - Using ChromeDriver directly...
[22:21:48] E/direct - Error code: 135
[22:21:48] E/direct - Error message: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
[22:21:48] E/direct - Error: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
at IError (D:\STS_workspace\jgh\node_modules\protractor\built\exitCodes.js:5:1)
at ProtractorError (D:\STS_workspace\jgh\node_modules\protractor\built\exitCodes.js:10:9)
at BrowserError (D:\STS_workspace\jgh\node_modules\protractor\built\exitCodes.js:51:9)
at Direct.getNewDriver (D:\STS_workspace\jgh\node_modules\protractor\built\driverProviders\direct.js:62:31)
at Runner.createBrowser (D:\STS_workspace\jgh\node_modules\protractor\built\runner.js:194:43)
at q.then.then (D:\STS_workspace\jgh\node_modules\protractor\built\runner.js:338:29)
at _fulfilled (D:\STS_workspace\jgh\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (D:\STS_workspace\jgh\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (D:\STS_workspace\jgh\node_modules\q\q.js:796:13)
at D:\STS_workspace\jgh\node_modules\q\q.js:556:49
[22:21:48] E/launcher - Process exited with error code 135
or
[21:19:23] I/launcher - Running 1 instances of WebDriver
[21:19:23] E/local - Error code: 135
[21:19:23] E/local - Error message: No update-config.json found. Run 'webdriver-manager update' to download binaries.
[21:19:23] E/local - Error: No update-config.json found. Run 'webdriver- manager update' to download binaries.
at IError (D:\STS_workspace\jgh\node_modules\protractor\built\exitCodes.js:5:1)
at ProtractorError (D:\STS_workspace\jgh\node_modules\protractor\built\exitCodes.js:10:9)
at BrowserError (D:\STS_workspace\jgh\node_modules\protractor\built\exitCodes.js:51:9)
at Local.addDefaultBinaryLocs_ (D:\STS_workspace\jgh\node_modules\protractor\built\driverProviders\local.js:40:23)
at Local.setupDriverEnv (D:\STS_workspace\jgh\node_modules\protractor\built\driverProviders\local.js:81:14)
at Local.setupEnv (D:\STS_workspace\jgh\node_modules\protractor\built\driverProviders\driverProvider.js:110:34)
at q.then (D:\STS_workspace\jgh\node_modules\protractor\built\runner.js:334:41)
at _fulfilled (D:\STS_workspace\jgh\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (D:\STS_workspace\jgh\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (D:\STS_workspace\jgh\node_modules\q\q.js:796:13)
[21:19:23] E/launcher - Process exited with error code 135
My conf.js looks like:
var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
exports.config = {
// directConnect:true,
specs: ['spec4.js'],
framework: 'jasmine2' ,
onPrepare: function () {
jasmine.getEnv().addReporter(new SpecReporter({
spec: {
displayStacktrace: true,
displaySuccessesSummary: true,
displayFailuresSummary: true,
displayPendingSummary: true,
displaySpecDuration: true,
},
}));
},
jasmineNodeOpts: {
defaultTimeoutInterval: 25000,
print: function () {},
},
I don't have selenium folder in the path node_modules/protractor/node_modules/webdriver-manager but I have package.json where I added "webdriver-update": "webdriver-manager update".
This is the output of npm run webdriver-update:
D:\STS_workspace\jgh>npm run webdriver-update
npm WARN invalid config proxy="http:"
npm WARN invalid config Must be a full url with 'http://'
npm WARN invalid config proxy="http:"
npm WARN invalid config Must be a full url with 'http://'
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "webdriver-update"
npm ERR! node v6.10.0
npm ERR! npm v3.10.10
npm ERR! path D:\STS_workspace\jgh\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'D:\STS_workspace\jgh\package.json'
npm ERR! enoent ENOENT: no such file or directory, open 'D:\STS_workspace\jgh\package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! D:\STS_workspace\jgh\npm-debug.log
It looks like you are either using directConnect or launching with a local driver provider (not having seleniumAddress or directConnect) in your configuration file. You need to run webdriver-manager update.
Previously I had extra flags to not download standalone or gecko with webdriver-manager update --standalone false --gecko false. This is no longer the case if you are starting via a local driver provider. You will need the selenium standalone jar file.
You could run this with a script in package.json. Something like:
"scripts": {
"webdriver-update": "webdriver-manager update"
}
Then execute this with: npm run webdriver-update. How do you check if the binaries are there? In your project, navigate to node_modules/protractor/node_modules/webdriver-manager/selenium/. This is where the update-config.json and your downloaded binaries are located.
You can try to update it like this, it will definitely update it in node_modules/protractor :
$ ./node_modules/protractor/bin/webdriver-manager update
Just execute webdriver-manager with npx command in your project folder;
npx webdriver-manager update
On MacOS, I resolved this error by adding the seleniumAddress to my Protractor config file (I was previously using directConnect, so commented that out):
// directConnect: true,
// baseUrl: 'http://localhost:4000/',
seleniumAddress: 'http://localhost:4444/wd/hub/',
I now start Protractor server by running: $ webdriver-manager start
And in a different terminal window, I start tests with: $ ng e2e
You just need to run this command and it fixes it - npm run webdriver-update it updates you webdriver in node_modules section under node_modules/protractor.
These 2 lines are the main culprits. Just try running that command and it should fix your issue.
[22:21:48] E/direct - Error message: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
[22:21:48] E/direct - Error: Could not find update-config.json. Run 'webdriver-manager update' to download binaries.
Hope that helps!
I ran npx webdriver-manager update command directly inside
$\node_modules\protractor\bin and it started working as expected.
traverse to the above mentioned folder inside your e2e and run command.
When I installed Java and updated Java Path in Windows 10, the problem was resolved.
In my case
npm run webdriver-manager update
updates only app\node_modules\webdriver-manager and not app\node_modules\protractor\node_modules\webdriver-manager\. No matter if I run that command directly from console or as package.json script.
I had to run
npx webdriver-manager update
inside app\node_modules\protractor\node_modules\webdriver-manager\.
Another solution would be this script:
"postinstall": "node ./node_modules/protractor/node_modules/webdriver-manager update"
With this I am able to proceed further
node node_modules/protractor/bin/webdriver-manager update

Categories

Resources