Deploying when NPM package is outdated - node.js

I want to deploy an Angular 12 app that uses d3-org-chart, which in turn imports d3-flextree. When I start my project using ng build it generates the following error:
./node_modules/d3-flextree/src/flextree.js:247:19-26 - Error: Should not import the named export 'version' (imported as 'version') from default-exporting module (only default export is available soon)
I can see that the error was fixed in the project GitHub repository in this commit, and I made the same change locally and it works fine.
Another developer has raised an issue on the project page to get the NPM package updated.
My issue is that the code was fixed in github, but not updated on NPM. So when I use npm install, or when I deploy my app in a docker container which then runs ng build it pulls down the outdated NPM version and the error occurs, preventing startup.
Obviously, this will be fixed when the maintainer updates the NPM package, but until this happens what is the least ugly solution to enable me to deploy my docker container without the error?

Related

Node-sass build issue with Docker

I am working in Docker to containerize the Angular 5 application. This app uses node-sass 4.7.2. The application works fine in the Windows environment. During "npm install", it downloads the node-sass or builds the same using the sass-library-path defined in .npmrc file.
But, there are a lot of issues during the docker image creation process. It automatically tries to download binding.node file from https://github.com/sass/node-sass/releases/download/v4.7.2/linux-x64-72_binding.node
But, there is no release for linux-x64-72. So, it downloads a dummy file(sized about 4KB) and throws "invalid ELF header" error.
If I specify some valid URL in sass-binary-path(https://github.com/sass/node-sass/releases/download/v4.7.2/linux-x64-59_binding.node), it throws "no module found" error.
I tried with npm rebuild node-sass as well. I saw a lot of answers from the internet as well. Many of the answers suggested me to copy node-modules from the local environment. You know, this is never an option with Docker. I can't ask developers to commit node-modules also in the repository.
Is there any way to resolve this issue? or Is there any simple solution to solve it in the angular application like not using node-sass?
There was a node sass version specified in the package.json. For the corresponding node-sass version, there is no library available for the os linux-x64-72_binding.node.
So, I upgraded the node-sass version in the package.json for which the Linux library was available.
Then, it downloaded the file without any issues.

Error from `ng serve` after running `ng update #angular/cli #angular/core` and unable to serve Angular project

In my Angular project, I was having errors while trying to build a docker image. I used ng update #angular/cli #angular/core and was able to resolve that error, and now I'm able to create a docker container of my project that is served.
However, now I cannot serve my project with ng serve because I get the following error:
An unhandled exception occurred: compiler.getInfrastructureLogger is not a function
getInfrastructureLogger is NOT a function I created, I'm assuming it's coming from a node mod. I've tried deleting the node_mod folder and install them again with npm install, but I still get the same error. I've tried cleaning my npm cache and I still get the error.
I went back a couple of commits (to before I ran ng update #angular/cli #angular/core) and then I'm able to run ng serve with no errors, but am then unable to create my docker images. I need to be able to use containers, so I have to use ng update #angular/cli #angular/core. But I also want to be able to serve my project as a standalone (plus it better for developing).
Does anyone have any advise on this error? Where it's coming from? Solutions?
I would really appreciate it. Thanks for any help you can give.
***To specify, I used ng update #angular/cli #angular/core --force it was the only for me to run that command.
My project is Angular 8, node node version 12.14.
The update in angular versions or one of the dependencies caused this error. We could help more if we knew what version of Angular you were coming from and what version you were updating to.
First, if you're upgrading to the latest stable Angular version (8.x), make sure you have node 10.9 or later installed.
Regardless, the Angular Upgrade Guide is an awesome tool that allows you to input the version you're coming from and the version you're going to and it will give you step-by-step instructions as to what you need to do in order to upgrade your angular app. Try upgrading one major version at a time following these instructions. It almost always resolves my problems.
Please note: It's better to upgrade one version at a time

error Couldn't find package "#jest/environment#^24.5.0" required by "#jest/reporters#^24.5.0" on the "npm" registry

I'm completely new to React Native and I'm following Facebook's tutorial at https://facebook.github.io/react-native/docs/getting-started using React Native CLI.
Yesterday, I've created a project successfully. Today, when I create an empty folder and run react-native init AnotherProject I get:
error Couldn't find package "#jest/environment#^24.5.0" required by "#jest/reporters#^24.5.0" on the "npm" registry.
What am I doing wrong? I'm on npm 6.7.0 and node 11.12.0.
Weird. I've ran the exact same command again, and it worked.

VSTS with gulp v.4.0.0

I'm having the gulp version of one of my projects. Previously we were using version 3.9.1 and we were hestitative updating.
After updating i have fixed all local issues and tested the project on a different computer (after updating the installed gulp there as well) it works fine.
Our automatic deployment however won't agree with me.
After a check-in our VSTS does the following steps
install npm
execute command
build project
However, this produces the following error.
Working directory changed to D:\a\1\s\MVC
Using gulpfile D:\a\1\s\MVC\gulpfile.js
C:\NPM\Modules\node_modules\gulp\bin\gulp.js:129
gulpInst.start.apply(gulpInst, toRun);
^
TypeError: Cannot read property 'apply' of undefined
at C:\NPM\Modules\node_modules\gulp\bin\gulp.js:129:20
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)
This error seems to be caused by an out of date cli version of gulp. But i can't figure out how to update this using VSTS.
Concrete problem
How do i update gulp cli in VSTS
What have i done already?
After some checking i saw the npm version installed was very old (3.10.8). I've dragged in a nodejs installer which updates to the latest version and gives me the latest version of nodejs, and a much newer version of npm (5.6.0) which i've used at on-hands computers to update the cli version. however i can't figure out how to do this in VSTS.
It seems that you are using Hosted Agent which the installed npm version is 3.10.8. You just need to add a Node Tool Installer task in your build definition and set it to use "8.x" version. It will install the 8.x version which include npm 5.6.0.
npm version before Node Tool Installer task:
npm version after Node Tool Installer task:
Try to install/update gulp-cli through NPM task:
BTW, the package in package.json will be installed on current project/folder instead of global, you need to call gulp command through npm command (scripts property of package.json) to use package in current project/folder or specify the path directly (e.g. ./node_modules/gulp/bin/gulp)
The solution that I found worked for me was to change the Pipeline from Hosted to Hosted VS2017.
I had completed a PR that upgraded the Gulp to 4.0, and the PR build completed but the CI build failed with strange results. After a lot of searching, I narrowed it down to the PR build already being set to Hosted VS2017 (it was building C# projects too that required them) and the CI build was only doing the Gulp build and was set to Hosted.

Error with 'babel-runtime' while trying to serve a Meteor app

I have recently been getting off the ground with Meteor and React. I followed the tutorial on the Meteor website with no problem.
Then I tried creating another project, trying to follow another tutorial (for an older version of Meteor). Somewhere along the line, Meteor started throwing up obscure errors. After trying to start fresh again, I ended up reinstalling Meteor and it stopped complaining.
However, I'm getting the same problems, again. Specifically, after creating a brand new project:
meteor create myproject
cd myproject
meteor
The server throws up the following error:
[...]
W20161109-03:53:42.862(1)? (STDERR) Error: The babel-runtime npm package could not be found in your node_modules
W20161109-03:53:42.862(1)? (STDERR) directory. Please run the following command to install it:
W20161109-03:53:42.863(1)? (STDERR)
W20161109-03:53:42.863(1)? (STDERR) meteor npm install --save babel-runtime
[...]
I do what I'm told and attempt to install babel-runtime package. The server manages to successfully get off the ground, but it then throws up the following error at run-time:
Uncaught Error: Cannot find module 'babel-runtime/helpers/slicedToArray'
at Function.require.resolve
This is all still working off a freshly created project, with no extra packages installed or code changed. I have tried looking online for solutions but, while there are lots of references to bugs that have been fixed, I haven't found anything. A couple of (questions)[Babel - Error: Cannot find module 'babel-runtime/helpers/typeof' on StackOverflow have suggested the following:
Reinstalling the NPM modules
rm -rf node_modules
meteor npm install
Updating NPM
meteor npm update -g npm
I am using Meteor 1.4.2, NPM 3.10.9, Ubuntu 16.04.1.
I was having the same issue. After a little digging, found this: https://github.com/meteor/meteor/issues/8019
* Installing the `babel-runtime` npm package in your application
`node_modules` directory is now required for most Babel-transformed code
to work, as the Meteor `babel-runtime` package no longer attempts to
provide custom implementations of Babel helper functions.
Consider trying it out by using the latest release candidate (not officially released yet):
meteor update --release 1.4.2.1-rc.1
And then:
meteor npm install --save babel-runtime
After upgrading to 1.4.2.1-rc.1 (and then subsequently upgrading to 1.4.2.1 this morning 11/9), the error was resolved.
Try adding package.json file inside your project directory and then run
meteor
npm install --save babel-runtime
in the command line.
You may have whitespace in your project name. All that you have to do is create another project without whitespace in the name. I know that it's quite difficult to detect the cause from the error message, but it is what it is.
I recently faced this issue with meteor 1.11.1 and the solutions here did not work. Turns out I had whitespaces in my project name (Ghughu Server V2) and all I had to do is create another one without the spaces (GhughuServerV2).
P.S. It works fine even if you have whitespace in the path to your project, you just can't have whitespace in the project name. Also, just renaming the directory doesn't work. Either you have to create a brand new project or change some configuration inside (which seems impractical if you're working in a newly created project).

Resources