How to connect npm with NuGet packages? - npm

I've started a Fable project using a starter template. In order to run it, I was previous successfully using npm run build.
Using Visual Studio, I installed some NuGet packages (Serilog, Dapper) but now when I call npm start, the terminal complains that the NuGet packages calls cannot be resolved:
ERROR in ./src/Project.App/App.fs
Module Error (from ./node_modules/fable-loader/index.js):
C:/Users/markr/git-repos/SampleProject/src/SampleProject.App/App.fs(95,12): (95,47) error FABLE: Cannot resolve Serilog.Log.Error
# ./src/SampleProject.App/SampleProject.App.fsproj 1:0-25 1:0-25
It makes this same complaint for all NuGet package calls. How do I make it so that I can run npm run build while using NuGet packages?

It turns out what I'm trying to do is impossible. Using SAFE architecture now to be able to properly implement a NuGet side (server) and an npm side (client)

Related

ng-zorro Error: Module not found when trying to run project

I'm using ng-zorro v14.1.1 for my angular 14.2.7. But when I try to run my angular application, I got errors when building the project looking for modules from ng-zorro and identifying it as not found even though the files existed in the project.
Here's the full view of the error:
Additional detail of the project:
Angular Electron project
Angular 14.2.7
Electron 21.2.0
Thanks in advance for helping!
I tried removing node-modules and re-install ng-zorro-antd using ng add ng-zorro-antd, and even npm install ng-zorro-antd if it makes a difference but to no avail, I'm still having the issue. Thus, can't run the project.
I have solved my problem. What I did was to install the modules that are mentioned in the error:
I ran the commands:
npm i d3-zoom --> this command gives you hint on what to do next when you're trying to run the project after the installation is finished, and it instructed me to run the next command below:
npm i --save-dev #types/d3-zoom
npm i dagre-compound
npm i d3-shape

How to link a globally installed node package to a project with yarn?

I have just started using yarn and I can't figure out how to link a globally installed package to a project. With npm I would just run npm link <package-name> but it doesn't work with yarn.
when I run yarn link <package-name> it gives this error:
yarn link v1.22.4
error No registered package found called "express".
info Visit https://yarnpkg.com/en/docs/cli/link for documentation about this command.
The link functionality is not really meant for linking global packages to a project. It is meant to link a package that you are working on to another project that you are working on. The fact, that the npm link command can be used to link globally installed packages to the current project is just an implementation detail of npm. From the yarn docs:
For the vast majority of packages it is considered a bad practice to have global dependencies because they are implicit. It is much better to add all of your dependencies locally so that they are explicit and anyone else using your project gets the same set of dependencies.
So you should just add the dependencies via yarn add <package-name>.

cant Install [.net core] packages using visual studio code(dotnet cli)

I using the latest asp core 3.1 framework. I am trying to setup my database but there is an issue. I can't seem to install the following packages
dotnet tool install --global dotnet-ef
dotnet tool install --global dotnet-aspnet-codegenerator
dotnet add package Microsoft.EntityFrameworkCore.SQLite
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Microsoft.EntityFrameworkCore.Design
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
I get the following errors. will appreciate it if any one can help with
a solution.
error NU1100: Unable to resolve 'dotnet-aspnet-codegenerator ' for '.NETCoreApp,Version=v3.1'.
error NU1100: Unable to resolve 'dotnet-aspnet-codegenerator ' for '.NETCoreApp,Version=v3.1/any'.
The tool package could not be restored.
Tool 'dotnet-aspnet-codegenerator' failed to install. This failure may have been caused by:
You are attempting to install a preview release and did not use the --version option to specify the version.
A package by this name was found, but it was not a .NET Core tool.
The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
You mistyped the name of the tool.
This happens when I try to install any of the packages.

Npm and Nexus Repository Manager 3.1: fail to publish npm libraries on the repo

I am trying to upload npm libraries on a Nexus Repository Manager 3.1. which is on a server. This server does not have internet access.
So, I did a npm install on another computer in order to have the needed libraries for npm. After that, I tried to publish them on the Nexus Repository Manager by doing: npm publish “lib” – registry “repo adress”.
It didn't work for 41 libraries: acorn, bluebird, clean-css, colormin, cssnano, csso, ent, event-stream, form-data, glob, gulp, is-extglob, kind-of, parse-glob, postcss-colormin, postcss-convert-values, postcss-discard-comments, postcss-discard-duplicates, postcss-discard-empty, postcss-discard-unused, postcss-filter-plugins, postcss-merge-idents, postcss-merge-longhand, postcss-merge-rules, postcss-minify-gradients, postcss-minify-params, postcss-minify-selectors, postcss-normalize-url, postcss-ordered-values, postcss-reduce-idents, postcss-reduce-initial, postcss-reduce-transforms, postcss-selector-parser, postcss-svgo, postcss-unique-selectors, q, spdx-expression-parse, useragent, void-elements, xml-char-classes, xmlbuilder.
Sometimes the errors are that librairies are missing. For instance when I try to publish the q library, the error was that grunt was missing. Therefore, I published it on the repo but I still have errors which are:
Failed to exec prepublish script
verbose stack Error: q#1.4.1 prepublish: grunt
Moreover, when I try to install the acorn library the problem was that a library was missing. When I published the missing library on the repo, another library was missing and again and again.
How do i do to publish all the libraries on the repo ?
I have the 3.10.9 version of npm.
I suspect the answer is because all of those packages have dependancies. So the errors you are getting are with the related dependancies. You could probably push the packages by removing the dependancies from the package.json however, when you went to use these packages they wouldn't work because they don't have the dependancies.
Thus, I don't think there's any viable workaround here. I believe the issue is because you're not on the internet and has nothing to do with Nexus.

Apache Cordova VS Community 2015 - Run Dependency Checker Fails

Apache Cordova Dependency Checker fails in VS Community 2015. It was previously working on this computer until I ran several VS and 3rd party tools updates. Here's what I've done to try to resolve the issue:
Installed VS / Apache Cordova (no error messages displayed) following article https://taco.visualstudio.com/en-us/docs/install-vs-tools-apache-cordova/
Run Apache Cordova Dependency Checker but VS freezes with the error message - VS 2015 has stopped working, windows will try to restart the program.
I restarted VS and cleared Cordova cache, checked environment variables (all good), then tried Apache Cordova Dependency Checker with the same freeze result.
I tried to update Apache Cordova with the fix option (no error messages) but received the same freeze results.
I completely uninstalled Apache Cordova, 3rd party tools (following article https://support.microsoft.com/en-us/kb/3016536), and VS community and then reinstalled them (no error messages) but received the same freeze results.
I installed Apache Cordova on another computer and the dependency checker phonegap app... worked. Unfortunately that's not a computer that I have access to.
What else can I do to resolve the Apache Cordova installation issue?
Thanks for any help,
Mike
Since my original post, I've had to resolve Visual Studio, Ionic, Cordova, Phonegap, plugin... environment issue several times. I've found the below works best:
Ensure platform matches plugin requirements, see platform in config.xml e.g. 6.1.1
Uninstall, reinstall latest jdk (adobe)
Clear MEF Cache - download the tool and follow instructions
Download/install latest node.js
Run the following from the command line:
Clear cache: Npm cache clean
Install latest npm: npm install -g npm
Uninstall cordova: Npm uninstall -g cordova
Reinstall cordova: Npm install –g cordova (note, this took 5+ tries to complete without errors. No other changes were made between runs. Not sure
why. Found others complaining about the same issue.)
Remove Android platform: Cordova platform remove android
Install Cordova platform add android#6.X.X (Note, as of 4/20/17 cordova and android compatibility issue. Build error - unable to find installed version of gradle. resolved by running (npm install -g cordova#6.4.0) and (cordova platform add android#6.1.2). Addt'l build errors, resolved by updating components in Android SDK Manager)
Uninstall/Reinstall plugins from the command line. For example:
cordova plugin remove phonegap-plugin-push
cordova plugin add phonegap-plugin-push variable SENDER_ID="YourID#"
npm install bower -g
Restart Visual Studio - Verify plugins were installed via config.xml
Install Ionic:
npm uninstall -g ionic
npm install -g ionic (note: to install specific version, npm install -g ionic#2.2.3)
$ ionic platform add ios
$ ionic platform add android (note: redundant, already added above)
I recommend putting as much of this as possible in a batch file with a pause between commands. Verify each command was successful, if not press ctrl+break at the pause to term the batch file early. The batch file is an easy way to restore your environment when everything breaks again. Stuff happens!
I also started using a VM (oracle virtualbox) for my development environment. That way I can backup my environment before making changes and easily restore. Don't forget to upload to GIT on a daily basis. GIT and VMs are my lifesavers.
Cool NPM commands:
npm list (lists all installed packages)
npm prune (removes packages not depended on by your project according to your package.json)
npm outdated (tells you which installed packages are outdated with respect to what is current in the npm registry but allowable by the version definition in your package.json. Make sure all up-to-date)
Please feel free to add/make suggestions to the above list.
-Mike