NestJS compiling without errors but VScode showing error - visual-studio

When I build the NestJS application inside a docker container with docker-compose, it builds without any errors. But the VS-code file explorer is showing all my files have errors with missing modules. Please refer to screen shots as below:
Please help.

Since you haven't run npm i or the yarn equivalent, node modules folder is not populated with the actual node packages/files.
Keep in mind that as #omidh said in his comment, when you run the docker command, you make an isolate environment/container with your code and all node_modules installed correctly. That means that your code is copied inside the container, then inside the container the command npm install is being run and your code is compiled/run eventually.
So that is the reason that your container runs without any error and your editor is showing errors.

Related

How to build VSCode app bundle from source

I'm trying to build VSCode from source on Mac, and make an app bundle. I tried following these instructions which suggest you can run gulp vscode-darwin to package VSCode for Mac.
I tried that. It definitely compiles some stuff and it doesn't print any errors, but there's no VSCode-darwin.app anywhere. What am I missing?
Ugh this is stupid. gulp vscode-darwin does build the app bundle, but it saves it in the parent directory. I.e. if you run npx gulp vscode-darwin in the root of the vscode repo, the output will be at ../VSCode-darwin, not in out, out-build, out-vscode, or .build as you might expect.

Yarn failing to start service based on "path/" argument must be of type string, Vue application, windows10

I am using a template, Vue cli3 application and it stopped working and I don't recall why. The error I am receiving is when I try to start the application I get this error.
yarn run serve
yarn run v1.16.0
error An unexpected error occurred: "The \"path\" argument must be of type string. Received type object".
info If you think this is a bug, please open a bug report with the information provided in "C:\\node\\TradeTriggers\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I can delete the node_modules and package.json.lock
I cannot do anything with yarn. No yarn install, yarn run serve, nothing and npm doesn't seem to want to run the application. I'm sorry there are a lot of tools to know in the JS world!
The machine is a windows10 machine and I cannot find yarn in my env variables, so the issue may lie there. I even tried installing the Yarn MSI but my version is still the one I installed through npm a while ago, still nothing.
I had problem that was caused by yarn looking at first the global settings file, ie global registry. It might be similar. On Windows, first check your yarn config path:
yarn config bin
Windows shows the path. Then in that folder, check whether you have a "rc" file, ie that is yarn configuration.
Try move this file out of the folder, for test. Have it as a copy somewhere else, where you can restore it if this does not help.
Then, once file is out, run your yarn commands again like you used to.
Sideline: on Linux, I had to remove a leftover buggy .yarnrc file in
/usr/local/share/.yarnrc
to get similar things working again. It was not a Vue app, but similar kind of error.
This error can occur when you are using Yarn Workspaces and have incompatible directories in the packages/ directory.
In my scenario, I used git subtrees to pull another repo into my project's packages/ directory. This directory had a package.json file, but it did not have compatible values for the fields required by Yarn Workspaces.
Moving the problematic package out of packages/ should fix this issue.

react-native set ENVFILE file for builds / archives

I'm really confused about production / development builds in react-native. I can get my app working on both iOS and Android by using the package scripts in the terminal
ENVFILE='/path/to/.env' react-native run-ios
ENVFILE='/path/to/.env' react-native run-android
Thats great for running my app locally, but how do I run this command when creating archives through xcode?
I successfully installed react-native-config and I have the variables I need in the JS and native files, its just the final step of using this is prod or staging builds for devices.
I've managed to create fastlane scripts that build and deploy my app (and I can reference my .env vars in fastlane scripts) but that still doesn't bundle my app with the .env vars inside. Its probably something obvious but i'm not understanding the concept at all.
Ive been referencing this tutorial here, and noticing the part about adding a pre-script to each Scheme in xcode:
".env" > /tmp/envfile
But I dont know what the current working directory on that script is, and Im using yarn workspaces so my node_modules folder is not at the root of the RN project (doesnt that even matter?). I've tried multiple paths to my .env from here but nothing works, but I also dont know how to test this script.
I've successfully gotten it to work using Fastlane. I followed this guide for the Fastlane setup:
https://github.com/thecodingmachine/react-native-boilerplate/blob/master/documentation/docs/3_Guides/BetaBuild.md
After following the guide, I moved the Fastlane directory to the root of the project (and updated all paths).
And after that added the ENV variable when running the command, for example: ENVFILE=.env.beta fastlane ios, which is easy to add as a script in package.json.
It's also possible to use the dotenv feature in Fastlane, see https://github.com/fastlane/fastlane/issues/13494#issuecomment-428941643.
Bottom line is that Fastlane will use the environment variable when running the packager, meaning that react-native-config will successfully pick it up and use the proper env-file.

I didn't run "Yarn add react-native" to a folder, will I run into issues when starting a project? I'm a noob and am just starting out

I used the CLI to install React Native, Node and Python but was not aware if I needed to save it to a file first.
I ran the yarn command:
➜ ~yarn add <package>
I would get this warning message when running yarn check:
➜ ~ yarn check
warning package.json: No license field
warning No license field
warning "jest-haste-map#fsevents#node-pre-gyp#^0.12.0" could be deduped from "0.12.0" to "node-pre-gyp#0.12.0"
Questions:
1. Do I only ~ yarn add when I start a project?
2. Since I've installed python, node, and react-native without creating a project folder will I run into issues down the road?
3. Do I add the json file with the licenses manually when starting a project with yarn?
4. Am I hopeless? lol
I've tried uninstalling and reinstalling from yarn and updating yarn. Also, I've tried installing python and node from Homebrew to see if that changes anything.
Below is a log of the output from the CLI after running ~ yarn check
Last login: Sat Aug 24 02:21:38 on ttys001
➜ ~ yarn check
yarn check v1.17.3
warning package.json: No license field
warning No license field
warning "jest-haste-map#fsevents#node-pre-gyp#^0.12.0" could be deduped from "0.12.0" to "node-pre-gyp#0.12.0"
success Folder in sync.
✨ Done in 1.99s.
Solution I figured it out! So after poking around I realized that once I started a project I had a yarn.lock and package.json file one level up in the directory where the file was located. What I did was I deleted yarn.lock and package.json associated with the folder in the directory. After that was complete I then went into my project and installed the correct packages.
You're not hopeless. This project may be, you've bitten off waaaay more than you can chew yet.
To answer your main question:
yarn add and it's cousin npm install will install the thing you tell them to in the node_modules folder in the directory you run the command in. The reason it's yelling at you is because usually you'll want to save the thing you installed as a dependency of your project, and you can't do that without a package.json file. You should run npm init to set up the package.json file for your project, then running yarn add will actually save it to the dependencies list so that you have a reproducible. If you have a package.json file already, it sounds like you maybe created it by hand (since it's missing a license field?) rather than have npm set it up for you, which is a bad idea.
Two more things:
React Native is awesome! ...But, it's a tool for people who already have good familiarity with Javascript command line/tooling/ecosystem/coding/React to build mobile apps. It is a lousy choice for a first project if you're just getting started with programming. Building a webpage with React is a lot easier, but even that may be too much.
If you really want to build a React Native app and you just can't wait look at this to get started.
But seriously, learn Javascript then npm then yarn then React then React Native. In that order.

Browserify working in some folders in windows, but not others

I'm trying to setup a build flow in a Visual Studio environment (13, on Windows 7) using browserify, and I am getting some strange behaviour trying to get browserify to work. I'm new to the environment as well as the technology, so I'm fairly confused here.
For the purposes of this test, my file structure is the same as the Basic API example found here: http://viget.com/extend/gulp-browserify-starter-faq I installed browserify using npm. It is running version 5.12.0
If I place app.js and hideElement.js in a simple directory, such as C:\Temp, and run
c:\Temp> browserify app.js
everything works fine. It bundles up all three of the required files, and spits them out. But if I run the browserify command from my project directory (C:\Users\\documents\visual studio 2013\Projects\ExcelConverter\ExcelConverterWeb), the following error spits out at me:
C:\Users\<name.redacted>\Documents\Visual Studio 2013\Projects\ExcelConverter\ExcelConverterWeb>browserify app.js
Error: SyntaxError: Unexpected token ? while parsing json file package.json
at fns(C:\Users\<name.redacted>\AppData\Roaming\npm\node_modules\browserify\node_modules\module-deps\index.js:402:30)
at fs.js:271:14
at Object.oncomplete (fs.js:107:15)
I've looked at the file in question, and I can't make heads or tails of it. So, what's going on here? How come browserify runs fine when I execute it from one directory, but not from the other? I appear to be using the same executable.
(I'm trying to use browserify as part of a gulp-based build process, but seeing as the errors produced by gulp are basically the same as those I see when I run from the command line)
I have run into "Unexpected token ?" problem. Changing package.json encoding type to 'ANSI' helped solving it. Most of the text editors have that option when "Save As" change Encoding option, then hit "Save"
See if that work for you.

Resources