I suddenly have an issue where our build server is now failing on a web build. Our first step after getting sources is to run a PowerShell script that does a few things, including running npm install (so we do not keep all the packages in source control).
The process gets to what should be the last item in the list, and then throws
error EISDIR: illegal operation on a directory, open 'K:\_work\4\s\Web\typings'
No changes have been made to any of the package config files. I have tried several different versions of Node.js, but still get this error. I have also tried installing the typings version we are using (1.3.1) globally on the server, and that does not work either.
The code being run by PowerShell:
Write-Host "START: running npm install"
[string] $pkg_dir = #(Join-Path $Env:BUILD_SOURCESDIRECTORY "\Web")
&npm --prefix $pkg_dir install $pkg_dir --loglevel "error"
Write-Host "FINISHED: running npm install"
Given this, I have no idea how it would even try to do anything with the offending directory, or where I would put any directory checking code (as mentioned in the comments).
Related
when trying to run this specific command:
lerna run -parallel lint
I consistently get this error:
EPERM: operation not permitted, scandir 'C:/Users/USER1/Application Data'
This is for a simple react app and npm install, start, etc all work as intended. It is only this command that does not work.
I have already tried many different solutions including:
npm clean cache -force
Run as administrator
Change permissions for both npm, project folder, AppData/Roaming to allow anyone to have full control
Delete all node modules and reinstall using "npm install -force", "npm cache verify", or "npm install --no-bin-links"
Disable anti-virus or Windows defender
Make sure no other node servers or scripts are running
Run on PowerShell, command prompt, VSCode, etc (tried pretty much every single CLI)
Install latest version of npm
Probably some others that I have since forgotten due to trying so many solutions
Also if the problem is actually related to npm and not lerna, then unfortunately I also cannot swap to using Yarn, as this is apart of a school project where a pre-commit script runs the lerna command and I cannot change it.
Please if anyone has encountered this issue, let me know.
On my local machine, npm run build works just fine. On my Docker image launched via Jenkins, I get issues like
Cannot find module: 'file-saver'. Make sure this package is installed.
You can install this package by running: npm install file-saver.
and
FAIL src/core/App.test.js
● Test suite failed to run
Cannot find module 'surface-nets' from 'vtext.js'
On my local machine, I have cleared the npm cache (npm cache clean -f), removed node_modules/, and reinstalled (npm i). I have even used npm update and the npm-check-updates package to update everything. I installed all peer dependencies. My local copy should be as wiped-clean as the copy within Docker is. In the Jenkinsfile, I put npm list and it shows surface-nets and file-saver and all my other packages. I also put ls node_modules/ and I can see the package folders are there. I have reduced my Dockerfile down to just 1 line: FROM node:current.
Why is it saying "Cannot find module" when the modules are installed?
The root cause of this issue is still unknown, but I did find out that the repository was corrupted. I ended up wiping the whole remote repo and git init-ing a new one, then pushing to that. I assume that corruption contributed to the issue at hand here.
I am trying to follow the UI Extensions Tutorial
At time code 02:36 I run the npm install && npm run login && npm run configure && npm run start command.
Afterwards I get the error: Cannot find module 'E:\Dev\Contentful\my-first-sidebar\node_modules\#contentful\contentful-extension-scripts\lib\index.js'.
I have globally re-installed the CLI and re-run the install/start command but still same error. I have also searched my hard drive for the contentful-extension-scripts\lib\ folder.
I see I have a contentful-extensions-scripts and contentful-extensions-scripts.cmd files and tried to run the cmd file but no use.
I am running on a Windows 10 box. Node version: 10.16.3, Npm version: 6.9.0
UPDATE
I found the GitHub Repo for contentful-extensions-scripts, cloned it and copied over the folder but now I get the error: Cannot find module 'parcel-bundler' and I am out of my depth.
Add the following line to package.json to fix it:
"#contentful/contentful-extension-scripts": "^0.14.0".
Running npm 6.11.3, node-gyp 5.0.3, VS2019 on Windows 10 v1903, getting this error:
Cannot find module %AppData%\npm\node_modules\node-gyp\bin\node-gyp.js (where %AppData% is expanded to the actual user-specific path).
The error only happens if the build is invoked via npm, i.e.:
npm run build
The package.json file scripts section:
"scripts": {
...
"build": "node-gyp build",
}
If node-gyp build is invoked manually outside npm context, the error is gone.
How do I get rid of the error and still use npm scripts for making builds?
Figured it out.
After upgrading to node-gyp 5 on a Windows 10 build system, I started getting the infamous Error: Cannot find module ... npm\node_modules\node-gyp\bin\node-gyp.js, caused by node_modules\npm-lifecycle\node-gyp-bin being pushed on top of my PATH by npm, exactly as described here.
None of the existing remedies I've found and tried could solve this issue for me, including installing the latest windows-build-tools. Here's exactly what I tried, in the following order:
manually clean up the mess and duplicates in System PATH and User PATH environment vars
reboot
choco unistall nodejs
rd /s %AppData%\npm\
rd /s %AppData%\npm\
choco install nodejs
npm install -g npm#latest
npm install -g node-gyp#latest
npm install -g typescript#latest
I was still getting the missing node-gyp.js error. What did help was to properly set npm config set node_gyp to point to the correct node-gyp.js, as suggested here. Yet somehow the script from that thread didn't work properly for me (as well some other PowerShell/Batch scripts I tried).
Eventually, I've come up with the following PowerShell 6 one-liner that did the trick for me:
pwsh -Command npm config set node_gyp "`u{22}$(Join-Path $(npm root -g) -ChildPath 'node-gyp\bin\node-gyp.js')`u{22}"
Hope this helps others and future-me. I'd still recommend going through the above bullet list for clean troubleshooting.
So I am trying to run gulp on our build server but keep getting the error above. Everything works fine if I log into the build server with my user account as I installed gulp globally under my account however when Jenkins runs my powershell script it fails with the error:
The term 'gulp' is not recognized as the name of a cmdlet error
So I tried to install globally in my script so that it installs with whatever user Jenkins uses.
Then I added npm -g ls to The powershell script and found that it is installed globally under a system user:
C:\Windows\system32\config\systemprofile\AppData\Roaming\npm >
gulp#3.9.0
Since I am still getting the error I took the advice from this post and added a path variable with the directory above however still the same error.
Anyone have ideas on what I can try next? Im stumped as to why it is not working.
Make sure the directory containing gulp.exe is contained in the $env:PATH environment variable. You can update the machine-wide PATH variable with the [Environment]::SetEnvironmentVariable() method.
Let's imagine the path to the gulp executable is C:\Program Files\gulp\bin\gulp.exe
# Directory containing exe
$GulpFolderPath = 'C:\program files\gulp\bin'
# Retrieve user-agnostic PATH environment variable value
$CurrentEnvPath = [Environment]::GetEnvironmentVariable('PATH','Machine')
# Check if PATH already contains gulp
if($CurrentEnvPath -split ';' -notcontains $GulpFolderPath)
{
# if not, update it
$NewEnvPath = $CurrentEnvPath,$GulpFolderPath -join ';'
[Environment]::SetEnvironmentVariable('PATH',$NewEnvPath,'Machine')
}
Finally a true GULP solution
After having searched for a solution the past two days without success, a colleague assisted me by running the following commands, the first installs gulp locally and globally and the second which I attribute the success for gulp finally running, installs the angular cli globally:
npm i -g gulp gulp
npm i #angular/cli -g
Afterwards I ran this command to update npm packages globally and locally; gulp finally worked:
npm install -g npm
Now running gulp -v yields success:
CLI version: 2.2.0
Local version: 4.0.2
NB: My OS is Windows 10 64 bit architecture latest updates on the 17th of July 2019. No proxy settings, no network ristrictions!!
If you do have a proxy before the internet configure your .npmrc file found by running the command npm config edit from your command line application:
proxy=x.x.x.x:PORT/
https-proxy=x.x.x.x:PORT/
prefix=C:\npm\node_modules
cache=C:\npm\cache