enter image description here
my code is returning the same value even if i change the code
I want to know what happened
Try the following:
Add the rimraf lib:
yarn add rimraf
Then create a new script in the scripts section of the package.json:
"prebuild":"rimraf dist"
I highly recommend you to remove dist file first and build and rerun your project.
rm -rf dist
npm run build
npm run start:dev
I'm not sure you faced the issue while adding a new model or updated the schema of orm module.
If yes, According to this link NestJS won't automatically copy your assets to the dist folder moreover as I described earlier is not compatible with glob static paths such as entities property in TypeOrmModule.
Related
I've got a firebase project with file structure like so:
node_modules/
package.json
functions/
node_modules/
package.json
If I npm install firebase in the parent project, everything works fine locally but the code fails on deployment because the child project is deployed without the parent project yet depends on firebase
If I install firebase in the child project, the parent app complains "Cannot find module 'firebase/storage'"
If I install firebase in both projects, the parent app complains "Cannot read 'path' of undefined" - debugging shows this is a firebase internal error
My ideal solution is to npm install firebase in the child project only, but somehow allow the parent project to access it? Is this possible? TIA
I've read about npm-link but not sure if this can help me or whether there is some other more suitable solution.
OPTIONAL READING: Why do I have a structure like this?
I ended up with this structure because the child project is a firebase project and firebase init created the functions folder and its contents. The child project is deployed to google cloud.
The parent project is a simple test bed app that I created and uses much of the code in the child project for testing purposes only, this code is not deployed.
Got the answer from here:
how to specify local modules as npm package dependencies
I ran this command in the parent project:
npm i --save ./functions/node_modules/firebase
Which adds an entry to the parent package.json as follows:
"firebase": "file:functions/node_modules/firebase"
Now everything works!
Obviously, this assumes that the child package is actually installed.
Using a preinstall script in the parent package.json to install the child packages first ensures this works smoothly.
My preinstall script entry looks like this:
"preinstall": "sh preinstall.sh"
And the script itself has the following contents:
#!/usr/bin/env bash
rm -rf node_modules
cd functions || exit
rm -rf node_modules
npm install --also=dev
When you run npm install the preinstall script is automatically executed before the actual install takes place.
Is there a way to restrict npm link to create the symlink only to point at ./dist?
I am struggling so far as I want to test my library (react component) locally before publishing.
In my package.json I have included the main (entry point):
"main": "./dist/index.js"
But still when I run npm link it links to the parent folder which has node_modules and so on.
This is causing problems cause now I have 2 react apps installed.
I thought of a way to exclude node_modules but I couldn't even find a way to do that.
This is actually simpler than expected. First run ng build to build your library project, then go under the dist folder and run npm link from there instead of the library root project. The symlink will be created pointing to the dist folder instead.
Using "main" parameter doesn't make sense because npm link use 'npm prefix' for create symlink
see here
You can use next hack:
Cd to project directory
Copy package.json from package to ./dist/package.json directory
Cd to dist directory
Run 'npm link'
It looks dirty but seem to only way to do it with npm link
I updated some libraries within my project and now I get an issue with the zlib within ng2-pdf-viewer.
There is also an issue created on github, that helped to fix it for now:
https://github.com/VadimDez/ng2-pdf-viewer/issues/322#issuecomment-389281242
The solution suggests to create a zlib folder within node_modules and add an empty index.js and a basic package.json.
This fixed the issue. But now I want to automate the process, since every time anyone runs npm install the pseudo folder is gone again.
Is there any way to create this folder with it's content automatically on npm install (maybe with mkdir or something)?
PS: The solution to put "browser": { "zlib": false } into the package.json didn't help in my case...
You should be able to create a script to create the directory, and then use a hook to run that script after you run npm install:
"scripts": {
"postinstall": "myCustomScriptToCreateFolder",
},
More reading:
npm Scripts Documentation
StackOverflow Post about this sort of thing
I am going to create an app which deals with Angular5(front-end), Nodejs(middle-end) and MongoDB(back-end).
Below is the folder structure:
Package.json: "start": "ng build & node server.js"
Now when I am start the app by npm start, It throws the following error:
"Unable to find any apps in .angular-cli.json."
I hope node server is looking for this file to load angular codes. But it lies inside angular folder.
If I place both angular and node codes in same place, it works well.
But it looks more clumsy and a bit confusing. I don't want to compromise with my folder structure.
Can anyone please help to achieve the app working on the same folder structure that I would prefer?
Thanks in advance.
it might be that your global #angular/cli installation got corrupt. You may try a cache clean and reinstall..
npm cache clean
npm -g i #angular/cli
If you use angular cli for creating the project, then looks something wrong in the package.json, (as I seen your comment on the previous answer)
first uninstall angular cli if already install by using
npm uninstall -g #angular/cli, then npm install -g #angular/cli after cli installation ng new [project name /folder name]
cd [project name /folder name]
ng serve --open
try once.
I got this same error in my current project and was confused because I'm running the application / ng serve in one terminal, but got this when I tried to generate a component from another terminal. .angular-cli.json was already there and correct. So what gives?
I realized that I used the shortcut to open VisualStudio Code's internal terminal -- which opened the terminal to the *root of the project * (like most IDEs). The project contains other things in addition to the Angular application folder that has the .angular-cli.json file in question. I just had to cd to the right folder and run ng g c again and things were fine.
In my case it was just a silly error. I thought I'd come back to share in order to save people a real headache for something so simple. I see that Shiva actually has mentioned this above, but I thought I would give a bit more detail so it doesn't get overlooked.
Reference URL: How to generate .angular-cli.json file in Angular Cli?
I’m developing a module in Node.js which I’ve npm-linked into another projects node_modules folder. I’d like to restart this other projects server upon file changes in my module. Nodemon ignores node_modules by default, but I assumed I could override this using nodemon --watch node_modules/my_module – but can’t get it to work. If I temporarily remove node_modules from Nodemons lib/config/defaults.js it works, which probably confirms that the problem has to do with overriding default behavior.
Using nodemon 1.2.1, I'm able to do the following to get watches working with an npm link:
$ nodemon --watch . --watch $(realpath node_modules/my_module)
Basically...you have to watch the directory you're in (your project directory), and then specify a watch to the symlink itself. nodemon by default ignores node_modules, so explicitly specifying the watch fixes this. You may try updating your version of nodemon if this doesn't work for you.