Lerna issue - Convector project "'<controller>.controller.ts' is not under 'rootDir' 'rootDir' is expected to contain all source files" - hyperledger

When a Lerna command fails (calling lerna add <package> lerna bootstrap), the project may break and experience some of the following issues:
Project folders erased
Compile (tsc) errors like File '/<home>/<project>/packages/<chaincode>-cc/src/<controller-name>.controller.ts' is not under 'rootDir' '/<home>/<project>/packages/<chaincode>-cc/src/'. 'rootDir' is expected to contain all source files.
It's a Lerna issue but may affect Convector CLI generated projects, since it's a dependency.

It usually happens when a package is imported incorrectly (it may happen due to automatically importing packages with VS Code, which usually set the packages wrong)
For example:
import { <controller>Controller } from '../../../<controller>-cc/src';
This will throw errors when trying to resolve packages.
The way to solve it is by fixing the import path like:
import { <controller>Controller } from '<controller>-cc';
Then clean things and refresh packages.
lerna clean
# Remove the root node_modules folder
npm i

Related

How to install node_modules only one time for one React JS project?

As I am implementing release automation of React JS project using Jenkins, it is required to download node_modules for a project only once and update successively. It doesn't mean one node_ modules for all projects. But one-time install for one project.
For example, Let's consider a project LoginReactApp.
I have to maintain a workspace like D:/jenkins/workspace/LoginReactApp.
So, I have to check out the source under D:/jenkins/workspace/LoginReactApp/LoginReactApp
and based on the package.json file, I need to download it under D:/jenkins/workspace/LoginReactApp/.
After the release process, the LoginReactApp project source will be deleted under D:/jenkins/workspace/LoginReactApp/ and the node_modules folder will not be deleted.
So, next time it is enough to check out only LoginReactApp project source D:/jenkins/workspace/LoginReactApp/ and it refers to already installed node_modules.
I have tried in command prompt below.
D:/jenkins/workspace/LoginReactApp/LoginReactApp>npm install
--production --f --prefix D:/jenkins/workspace/LoginReactApp/
Is it right? For next time it behaves differently.
How to install node_modules only one time for one React JS project?

. Why I am getting an error message? Building a React App

I wanted to start practicing with React to make a simple app. Went ahead and downloaded homebrew and node onto my computer. As I build my app with yarn install I get to the end where it tells you happy hacking. But when I run yarn start it gives me an error message.
-There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.
The react-scripts package provided by Create React App requires a dependency:
"eslint": "^6.6.0"
Don't try to install it manually: your package manager does it automatically.
However, a different version of eslint was detected higher up in the tree:
/Users/zacharyschneider/node_modules/eslint (version: 5.16.0)
Manually installing incompatible versions is known to cause hard-to-debug issues.
If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.
To fix the dependency tree, try following the steps below in the exact order:
1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
2. Delete node_modules in your project folder.
3. Remove "eslint" from dependencies and/or devDependencies in the package.json file in your project folder.
4. Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:
5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
6. Check if /Users/zacharyschneider/node_modules/eslint is outside your project directory.
For example, you might have accidentally installed something in your home folder.
7. Try running npm ls eslint in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed eslint.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.
P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
zacharyschneider#Zacharys-MBP %
A way to solve this issue or help me understand what is going on that would be great or point me in the right direction to find resources.
Thanks for your Help
It seems like you have installed es-lint 5.16.0 manually, and it conflicts with the needed version (6.6.0).
Have you tried the steps suggested in the error message?
Do you explicitly tell the es-lint version in your package.json? Could you share your package.json if you continue to experience the issue?

Unable to restore nuget packages with "WARNING: Invalid parameter" error

I'm trying to build a Xamarin Android project at my build server (Mac OS X) but I'm unable to restore some of nuget packages (3 or 22). These three packages can be downloaded but for some reason couldn't be copied to the workspace.
I cleaned the workspace, removed nuget cache - same result.
Restoring NuGet package Xamarin.GooglePlayServices.Gcm.29.0.0.1.
Restoring NuGet package modernhttpclient.2.4.2. Restoring NuGet
package Xamarin.GooglePlayServices.Analytics.29.0.0.1. Adding package
'Xamarin.GooglePlayServices.Analytics.29.0.0.1' to folder
'/Volumes/Storage/Jenkins/jobs/Build1/workspace/packages'
Adding package 'Xamarin.GooglePlayServices.Gcm.29.0.0.1' to folder
'/Volumes/Storage/Jenkins/jobs/Build1/workspace/packages'
Adding package 'modernhttpclient.2.4.2' to folder
'/Volumes/Storage/Jenkins/jobs/Build1/workspace/packages'
WARNING: Invalid parameter WARNING: Invalid parameter WARNING: Invalid
parameter
After a restart and packages folder cleanup it started to work fine. Just use -Verbosity detailed command to get more insights on an issue:
https://docs.nuget.org/consume/command-line-reference
Take into account that the install, update and restore commands has different way to define verbose level of output.

Failed to load package in Dart

When I try to import a package with the syntax import 'package:markdown/markdown.dart';, I get no error in Dart Editor but when I run the dart application, the debugger shows me the message:
An error occurred loading file: package:markdown/markdown.dart
Failed to load resource
chrome-extension://gfjabgeipkcfopofkhjimepepnomcidk/dart/packages/markdown/markdown.dart
But when I write the whole path (import "../../packages/markdown/markdown.dart";) everything works fine. I cannot understand why the syntax package: doesn't work in my code though it works in Dart Editor's own examples.
You can see the Chrome app architecture below (I'm loading a package from translator.dart):
You should have the package added as a dependency in pubspec.yaml (which I assume you do).
Also try running following:
delete packages folder
delete pubspec.lock
run pub get to fetch the
dependencies again.
I think in your md_to_html folder you need a link to the 'packages' directory for the shortform to work. I seem to remember this happening when the workspace is built but I'm not sure now which command triggers it, have a look at the current pub docs.

Pub does not download dependencies on Windows 7 after the update to lib v2 (SDK 0.3.1_r17328)

After the update to the version 0.3.1_r17328 of Dart SDK and Dart Editor I have some trouble to import some library particulary Args library. I have the same problem both directly importing Args or importing Web_ui where Args is one of the dependencies.
Here is my pubspec.yaml:
name: notes
description: A sample application
dependencies:
web_ui: 0.3.0+1
or:
name: notes
description: A sample application
dependencies:
args: 0.3.1+1
Here is the error generate from build.dart
Unable to open file: C:/Users/Fabio/Dropbox/progetti/note/packages/args/args.dart'package:web_ui/component_build.dart': Error: line 25 pos 1: library handler failed
import 'package:args/args.dart';
'file:///C:/Users/Fabio/Dropbox/progetti/note/build.dart': Error: line 1 pos 1: library handler failed
import 'package:web_ui/component_build.dart';
I solved the problem. It seems that the Cache folder (Pub) has been corrupted.
I have deleted the folder Cache: C:\Users\<UserName>\AppData\Roaming\Pub
Then i run pub install from command line and it works.
Unfortunately, I was getting the same error with my windows XP machine.
In the end, I logged into my windows 7 machine and was able to
download the packages, zipped them up and pasted the libraries into my
windows XP dart editor. Success!
I had no reason to believe I had the exact proxy issue #shindokaku had as I am using my home computer.
I tried all the suggestions on deleting the .cache files, pub.lock files and the packages folder and retrying. I uninstalled dart editor and tried again. I also tried using the git resources to download web-ui and running commands through the command line to no avail
Including suggestions in this similar questions:
cannot-find-referenced-source-packages
is-there-a-workaround-for-pub-dependency-resolution-through-proxies
This problem has been haunting me over and over for a few weeks. I am not using Windows, so this answer is not intended to help the original poster who is using Windows 7.
If you are using Linux here are the steps I use to repair corrupted pub cache.
Go to the top level directory of your app. You should see at least pubspec.lock, pubspec.yaml, a folder named packages, and a folder named web.
Delete your pubspec.lock, and packages folder.
[Make sure you aren't storing your own libraries in the packages folder]
cd ~/dart/myApp/
rm -r packages
rm pubspec.lock
Now once you have removed these files:
pub cache repair
Note 1: if your dart-sdk is not in your systems $PATH, than you will want to use the absolute path to the sdk when using the above command. Comment if you need that explained.
Note 2: This is working solution with Dart 1.5.3. I have not tested this on earlier versions.
Try deleting your pubspec.lock file and packages directory in the root folder of the project. Then run pub install again, when things get wacky thats what I do.
You should try to run pub update. I have sometimes found that this doesn't work as expected from the editor, but generally works quite smoothly when called from the command line.

Resources