问题
I fixed this or a very similar issue with building in debug (and I assume in a release version) my Visual Studio 2015 Community TACO Apache Cordova project (the one I'm working on or a blank new project from the template - which is what I've provided output from here, below, the blank one) just about 24 hours ago, but now the problem has 'mysteriously' reappeared.
Error Cannot find module 'C:\Users\myusername\Documents\Visual Studio 2015\Projects\BlankCordovaApp3TestZ\BlankCordovaApp3TestZ\node_modules\vs-tac\app.js'
(the last part of the path does not exist, i.e. there is no \node_modules\ folder. There is a vs-tac folder here, of course,
C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\APACHECORDOVATOOLS\packages\vs-tac
,as mentioned in the BUILD output at the bottom. Some updated info: I see that the project which I was successfully debugging before I un/re-installed all my project plugins does have the node_modules folder with many sub-folders but not vs-tac.
I had everything working: debug on Ripple, Android AVDs, my Android device. Two days ago I cleared the Cordova cache (for a stupid reason) and started getting the error.
After hours of troubleshooting, I got it working again, I thought by running (my last try):
npm install -g npm
Before that I had attempted fixing by -->
- Clearing the cache again
- Renaming the folder: C:\Users\myusername\AppData\Local\Microsoft\Phone Tools\CoreCon (So that VS recereates it)
- Renaming the folder C:\Users\myusername\AppData\Roaming\Microsoft\VisualStudio\MDA\vs-npm (So that VS recereates it)
- Tried to re-install vs-tac (no quotes on the path, didnt work, but I got the issue resolved anyway - today I used the quotes)
- Verified the npmrc file had the fix: i.e. its content was --> prefix=C:\Users\myusername\AppData\Roaming\npm
After again being able to debug, I came to a point today where i decided to uninstall my project's jquery module (2.2.3), and it looked like i need to uninstall jquery.mobile (1.4.5) and Bootstrap (3.3.7) also to do so, since I thought I might have a too high version of jquery causing an issue with my project's code. I re-installed the same except jquery at 2.1.0.
After the module uninstall/reinstall just mentioned the vs-tac issue came back! Also, for the first time, an NPM dependency not installed issue in the dependency tree! After a little messing around, I opened a new Apache Cordova project from the template... the dependency issue is gone but not the vs-tac build issue.
I have tried all of the above fix atttemps again today and cannot resolve it this time, so far...
Here is the output from some of those attempts at fixing my issue today (from an Admin Node.js command prompt) -->
C:\Windows\System32>npm install -g npm
C:\Users\myusername\AppData\Roaming\npm\npm -> C:\Users\myusername\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
C:\Users\myusername\AppData\Roaming\npm\npx -> C:\Users\myusername\AppData\Roaming\npm\node_modules\npm\bin\npx-cli.js
+ npm@5.3.0
updated 1 package in 64.141s //This update seems to happen every time I run this command, which is odd for something global
C:\Windows\System32>npm install -g "C:\Program Files\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\ApacheCordovaTools\Packages\vs-tac"
C:\Users\myusername\AppData\Roaming\npm\vs-tac-cli -> C:\Users\myusername\AppData\Roaming\npm\node_modules\vs-tac\vs-tac-cli.cmd
+ vs-tac@1.0.42
updated 1 package in 4.406s
ENVIRONMENT INFORMATION -->
Microsoft Visual Studio Community 2015 Version 14.0.25431.01 Update 3
Microsoft .NET Framework Version 4.7.02046
Installed Version: Community
Visual Studio Tools for Apache Cordova Update 10
Microsoft Visual Studio Tools for Applications 2015 00322-20000-00000-AA328
JavaScript Language Service 2.0
JavaScript Project System 2.0
In VS Tools > Options > Projects and Solutions > External Web Tools I have:
C:\Program Files\nodejs (at the top, then)
.\node_modules\.bin
$(VSINSTALLDIR)\Web\External
$(PATH)
$(VSINSTALLDIR)\Web\External\git
(all above are checked - not changed recently)
I don't think what is in VS Tools > Options > Tools for Apache Cordova > Environment Variable Overrides is relevant in this case and did not include.
Cordova CLI --> 6.1.1 (per the test project's config.xml)
// From VS Package Manager Conole -->
Path
----
C:\Users\myusername\Documents\Visual Studio 2015\Projects\BlankCordovaApp3TestZ\BlankCordovaApp3TestZ // this is my new template test project
PM> node -v
v6.9.1
PM> npm list cordova
BlankCordovaApp3TestZ@1.0.0 C:\Users\myusername\Documents\Visual Studio 2015\Projects\BlankCordovaApp3TestZ\BlankCordovaApp3TestZ
`-- (empty)
PM> npm list -g cordova
C:\Users\myusername\AppData\Roaming\npm
`-- cordova@7.0.1
PM> cordova platform version android
Installed platforms:
Available platforms:
android ~6.2.2
blackberry10 ~3.8.0 (deprecated)
browser ~4.1.0
webos ~3.7.0
windows ~5.0.0
Full BUILD Output (for DEBUG ANDROID DEVICE) -->
1>------ Build started: Project: BlankCordovaApp3TestZ, Configuration: Debug Android ------
1> ------ Ensuring correct global installation of package from source package directory: C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\APACHECORDOVATOOLS\packages\vs-tac
1> ------ Name from source package.json: vs-tac
1> ------ Version from source package.json: 1.0.42
1> ------ Package not currently installed globally.
1> ------ Installing globally from source package. This could take a few minutes...
1> Each package is licensed to you by its owner. Microsoft is not responsible for, nor does it grant any licenses to, third-party packages. Some packages may include dependencies which are governed by additional licenses. Follow the package source (feed) URL to determine any dependencies.
1> ENOENT, no such file or directory ''
1>MSBUILD : cordova-build error : module.js:338
1> module.js:338
1>MSBUILD : cordova-build error : throw err;
1> throw err;
1>MSBUILD : cordova-build error : ^
1> ^
1>MSBUILD : cordova-build error BLD401: Error : BLD00401 : Could not find module 'C:\Users\myusername\Documents\Visual Studio 2015\Projects\BlankCordovaApp3TestZ\BlankCordovaApp3TestZ\node_modules\vs-tac\app.js'. Please Go to Tools --> Options --> Tools for Apache Cordova --> Cordova Tools --> Clear Cordova Cache and try building again.
1> Error Cannot find module 'C:\Users\myusername\Documents\Visual Studio 2015\Projects\BlankCordovaApp3TestZ\BlankCordovaApp3TestZ\node_modules\vs-tac\app.js'
1>MSBUILD : cordova-build error : at Function.Module._resolveFilename (module.js:336:15)
1> at Function.Module._resolveFilename (module.js:336:15)
1>MSBUILD : cordova-build error : at Function.Module._load (module.js:278:25)
1> at Function.Module._load (module.js:278:25)
1>MSBUILD : cordova-build error : at Function.Module.runMain (module.js:501:10)
1> at Function.Module.runMain (module.js:501:10)
1>MSBUILD : cordova-build error : at startup (node.js:129:16)
1> at startup (node.js:129:16)
1>MSBUILD : cordova-build error : at node.js:814:3
1> at node.js:814:3
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========
New stuff I'm trying today -->
npm config set prefix %APPDATA%\npm
npm config set cache %APPDATA%\npm-cache
(because I also copied vs-tac into my roaming folder at some point)...this had no effect on build.
Also, realized my config.xml had CLI set to 6.1.1, so i changed this to match the globally installed version, 7.0.1 - no effect on build.
Any assistance much appreciated.
Thanks in advance.
来源:https://stackoverflow.com/questions/45623021/error-when-building-apache-cordova-project-in-visual-studio-could-not-find-mod