Angular: ng new error when I create an angular project - node.js

I have this error using ng new project_name:
An invalid configuration file was found ['angular.json']. Please delete the file before running the command.
I am getting this error I don't know how to get the solution.
I uninstalled #angular/cli and installed again
npm clean cache doesnt work too (I dont know if it is problem of my npm version
npm version is 6.4.1
node version is 8.11.1
what do i need to solve the problem?

If you are using the terminal of IntelliJ IDEA while there is a angular project already imported in the IDEA, it is the problem of the IDEA.So, open the command promt of your windows and create the project.
I did this and I was able to create the project.

The problem seems to be the _ in project_name resulting in the following error:
Schematic input does not validate against the Schema: {"name":"project_name","version":"6.0.1","newProjectRoot":"projects","skipInstall":false,"linkCli":false,"skipGit":false,"commit":null}
Errors:
Data path ".name" should match format "html-selector".
Replace _ e.g. with -.
Further readings:
Error when creating new project with Angular-CLI 6.1.2
Style Guide

Setting the working directory in IntelliJ's Karma task, to the Angular project's main directory, also fixes the problem.

I deleted the file in c:\users\XXX\.angular.json and it was running ok.

Run following if file is hidden. Open Terminal, run mv /Users/shivammishra/.angular.json /Users/shivammishra/angular.json.txt.
mv command will move the file to new location (angular.json.txt) and you can then delete.

Angular.js & Wrong Directions.
First of all, open a file called angular.js in the root folder.
And check if you add some wrong Directory. like the style or something like that. as example.
Suppose you add the bootstrap dependency and you want to add it to your project you will go to the angular.js and add it in the style configuration. so you will add it as the below:
"styles": [
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.css"
],
Check if you add double dot .. not one dot in the path like the below:
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
Or you maybe add it in the following format:
"/node_modules/bootstrap/dist/css/bootstrap.min.css",
or
"node_modules/bootstrap/dist/css/bootstrap.min.css",
The correct format is :
"./node_modules/bootstrap/dist/css/bootstrap.min.css",

Related

Swagger 3.0.1 server generator

When I generate a nodejs-server with swagger 3.0.1 in the online tool https://editor.swagger.io/ and try to npm start the project I always get the following error:
Error: Cannot find module './middleware/swagger.router'
Short-term fix: you can get it to run until the maintainer of oas3-tools and Smartbear (for this server generator) fixes their respective parts.
PROBLEM A: oas3-tools build script isn't copying the 'middleware' over to the 'dist' directory.
To fix this:
Start your generated server (this will run npm install and create the dist folder in node_modules/oas3-tools)
Go into ./node_modules/oas3-tools and manually copy the missing src/middleware to the dist folder.
Now that you have a middleware folder in your dist folder, run the following typescript compile command against it: tsc dist/middleware/
PROBLEM B:
The next issue is a typo on the path to the swagger document is incorrect.
To fix this:
In the index.js file of your generated server, change the string 'api/openapi.yaml' to 'api/swagger.yaml'
POSSIBLE EXTRA PROBLEM:
You may need to manually transpile your .ts files. Please see #Alex's comment below if you also run into this (i.e. error TS6053: File 'dist/middleware/.ts' not found. Found 1 error)
Swagger Editor bug posted here: https://github.com/swagger-api/swagger-editor/issues/2086
Oas3-tools bug posted here: https://github.com/bug-hunters/oas3-tools/issues/17
The latest version of oas3-tools is 2.1.2 is screwed up. Use 2.0.2 for now.
oas3-tools : "2.0.2"

Ember Cli not compiling with broccoli-emblem-compiler

I am trying to set up this repository locally https://github.com/lrdiv/ember-soundcloud and i have come across to this issue with broccoli-emblem-compiler. See the image in attached
From my understanding the broccoli-emblem-compiler is not able to compile my emblem templates and i don't know how i can figure it out.
These are all the steps i have done to install and set up the project with Ember-Cli
ember new soundcloud
ember install:addon ember-cli-coffeescript
ember install:npm broccoli-emblem-compiler
I have deleted the app folder and replace with the project https://github.com/lrdiv/ember-soundcloud that i have cloned
then i have installed the other node modules required
ember install:npm broccoli-static-compiler
ember install:npm broccoli-merge-trees
ember install:npm install body-parser
and at the end i run
ember server , and in my terminal i get that error i have attached.
What can i do now to sort this out? What's really the problem?
I did many things to try to fix this. One was replacing the project broccoli-emblem-compiler with this line in the project settings:
"broccoli-emblem-compiler": "git+https://github.com/cascalheira/broccoli-emblem-compiler.git"
At some time the error went away, I think it was when I used this repository. It is mentioned in the other issues.
I ran into problems with broccoli-emblem-compiler, but just had success with ember-cli-emblem-hbs-printer -
https://github.com/201-created/ember-cli-emblem-hbs-printer
I was able to solve this by specifying a version of emblem.js in my package.json file.
Specifically, I added the following line:
"emblem": "0.3.14"

Issues installing swiper.js (node.js/grunt noob)

Having issues getting swiper.js to work. Requires grunt/bower. I'm completely new to js generators and am only able to get through about half the walkthrough before running into issues.
When I type $grunt dist into terminal, I get the following response: -bash: dist: command not found
What step am I missing?
Followed the idangerous steps to the letter: http://www.idangero.us/sliders/swiper/plugins/scrollbar.php
I have most often see "X command not found" for one of the following reasons:
The project's Grunt dependencies aren't installed or aren't installed properly
Your Gruntfile is mis-configured or missing
To fix this, first make sure there is a package.json file in your project. This will tell the npm what dependencies the project has and install them accordingly (assuming the package.json file is also configured correctly).
Next, make sure you have installed grunt correctly.
If you're still having issues, open your Gruntfile and search for:
grunt.registerTask('dist
This will show where the "dist" task is being defined. If you for some reason don't find it, then there's your problem. If you do find it, then check the proceeding commands inside square brackets that look like this:
grunt.registerTask('dist', ['clean', 'dist-css', 'copy:fonts', 'dist-js', 'dist-docs']);
'clean', 'dist-css', etc. are all other tasks defined in the Gruntfile, and there could be an issue with those as well.
If there's an issue with your package.json or Gruntfile, then trying re-installing the project with bower and repeat the above steps to ensure that it's not an issue on your end.
If it's not, then something is probably wrong with the author's source code.

nodejs module.js:340 error: cannot find module

I installed nodejs in C:\Program Files (x86)\nodejs
then I created a .js file and saved it in my desktop just to output 'hello world' in the console:
console.log('hello world');
When I tried to run the file from the command prompt:
C:\Users\Laura>cd desktop
C:\Users\Laura\Desktop>node nodeTest.js
I get:
module.js:340
throw err;
^
Error: Cannot find module 'C:\Users\Laura\Desktop\testNode.js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
I read many other related questions, and some of them recommend to run the install, and so I did.
C:\Users\Laura>npm install -g express
But no luck, still getting the same error message.
EDIT: This answer is outdated. With things like Yarn and NPM 5's lockfiles it is now easier to ensure you're dependencies are correct on platforms like Heroku
I had a similar issue related to node_modules being modified somehow locally but the change was not reflect on Heroku, causing my app to crash. It's relatively easy fix if this is your issue:
# Remove node_modules
rm -fr node_modules
# Reinstall packages
npm i
# Commit changes
git add node_modules
git commit -m 'Fix node_modules dependencies.'
git push heroku master
Hope that helps for others with a similar issue.
I was having the same problem with a server someone had written a while back. It turns out I didn't have a few things installed that the script required.
This question was helpful to me.
I ended up being able to use:
npm install yourMissingDependency
Although in your instance it may just be a file that it doesn't have a path to.
You could try putting that file in the same folder you are running the node script from.
I think the issue is the NODE_PATH environment variable. I had the same problem but once I issued (on Windows)
set NODE_PATH=C:\Users\MyUser\node_modules
then all worked ok.
Cheers,
Restart your command prompt and check your path variable (type: path).
If you can't find find nodejs installation dir from output add it to the path variable and remember to restart cdm again...
I had a nearly identical issue, turned out my JS file wasn't actually in the folder I was calling it from, and I had gone one folder too deep.
I went up one directory, ran the file, it recognized it, happily ever after.
Alternatively, if you go one folder up, and it gives you the same error, but about a different module, take that same file in your parent folder and move it into the subfolder you were previously trying to run things from.
TL;DR- your file or its module(s) is not in the folder you think it is. Go up one level
Try typing this into the Node command-line environment:
.load c:/users/laura/desktop/nodeTest.js.
It should work for what you're trying to do.
If you want to call the file directly, you'd have to have it in the root directory where your Node installation resides.
Hi fellow Phonegap/Cordova/Ionic developers,
I solved this issue by doing the following
1. C: drive -> Users -> "username" eg. john -> AppData -> Roaming
2. Inside the "Roaming" folder you need to delete both "npm" and "npm-cache"
folder.
3. Now build your project, and it should work
Happy coding!!!
I faced the same problem. I just copied the testNode.js file(that contain the test code) and pasted into the root of nodejs directory manually. I tried this command C:\Program Files (x86)\nodejs>node testnode.js
Bingo! I received this message.
Then I typed this url in a browser and received the message "Hello World".
Hope this help somebody.
You need to:
Remove the tick of Hide extensions for known file types from Windows Explorer folders option
Your file will appear as testNode.js.txt
Remove the trailing .txt so as the file to be resolved as JS file
That's it, now it works!
I had the same problem then I found that I wasn´t hitting the node server command in the proper directory where the server.js is located.
Hope this helps.
Try npm install --production and then npm start.
Easy way for this problem
npm link e
I also got this issue and this was due to wrong path that we mention while running. Check your file path and also make sure that there is no space between the name of your directory name.
Try npm start in Node.js Command Prompt.
Look at the end of the messages - it gives you the path of log file in "Additional Logging Details ..." something like c:\users\MyUser\npm-debug.log
Open this file in Notepad and find the real address of Node.exe :
something like C:\\Program Files\\nodejs\\\\node.exe
Try cd to this path
Call node.exe + <full path to your server file.js>
Server is listening on port 1337 !
I had the same problem, but finally I tried copying the Node_modules folder in the same project folder, and it worked.
I executed following command and it works for me.
PM> npm install ee-first ee-first#1.1.0 node_modules\ee-first
While i tried to run my first node application i had encountered the same issue but when i tried to see what the issue might be it was the path of the file. I was running the node .js from different location and hence encountered the issue. When i fixed the path this worked fine.
In my case, i got this error because i was just in the wrong directory. So node couldnt find the module that i wanted to run. Just be sure your node file is in your Desktop directory.
If you are using a framework like express, you need to put the package.json file into the folder you are using and don't forget change main name.
Remove the fs extra from the path -
path: 'D:\\FrontEnd Dev\\Git projects\\Appname-master\\node_modules\\webpack-manifest-plugin\\node_modules\\fs-extra\\package.json',
requestPath: 'fs-extra'
And run the command npm i
Make sure you saved the file as JavaScript. Un check 'Hide extensions for all known type' check box in Folder Options window will show you the correct file extension(Folder>>view>>Option).
Faced the same problem while trying to run node-red.
node <directory structure where js is located>/red. js
In my case it was :
node AppData/Roaming/npm/node_modules/node-red/red.js

Error code: 800A1391 Source: Microsoft JScript runtime error Running Grunt - Module is undefined

New Grunt user here who is using a lot of new tools (npm nodejs) today.
I've got Grunt "installed" and have been able to create a grunt.js file using the init task as described here: http://net.tutsplus.com/tutorials/javascript-ajax/meeting-grunt-the-build-tool-for-javascript/ and here: https://github.com/cowboy/grunt/blob/master/docs/getting_started.md. But whenever I run the "grunt" command I get an error:
Windows Script Host
Script: c:\users\[]\Documents\code\grunt\grunt.js
Line: 2
Char: 1
Error: 'module' is undefined
Code: 800A1391
Source: Microsoft JScript runtime error
As explained in the FAQ, you need to type grunt.cmd instead on Windows because the OS tries to launch grunt.js
Or you can install grunt-cli globally instead. This package will run any version of Grunt if it's been installed locally to your project.
SOLVED !!
So, this problem occur because windows by default associative < *.js > files
with >>
"Microsoft Windows Based Script Host".
grunt need to open by default with (grunt.cmd).
it easy to slove, by change default app (open with..)
Guide :
Go to any javascript file with "js" extension. (any file)
Right-Click(mouse) > Properties > "Opens with:" Change...(button)
Choose Notepad ( or any javascript IDE ).
PROBLEM SOLVED ! :)
good luck
If you're getting a "Microsoft JScript runtime error" that means that node.js isn't even getting invoked; instead Windows Script Host is trying to run your code. That's probably a problem with filetype associations; IIRC Windows defaults to trying to execute a ".js" file with WSH. You may wind up having to create a shortcut to your script, specifying a command line (probably something like "node %1") and a starting directory in order to make sure that it's executed properly.
It would help if you could tell us exactly how you're trying to invoke your code.
it seems that in the latest versions of the grunt modules, you would have to do the following to have it work under windows:
remove any globally installed grunt
npm uninstall -g grunt
install grunt-cli globally
npm install -g grunt-cli
install grunt locally into your project
npm install grunt
installing grunt (v0.4.x) globally does not seem to create the necessary grunt.cmd anymore. it seems that the recommendation is now to have grunt installed locally to be able to use version-specific Gruntfiles
As Florian F suggested, running grunt.cmd works. This is because of the process Windows is looking for your grunt command.
When typing grunt -h Windows will proceed to look for the following files:
./grunt.cmd
./grunt.* (grunt.js is found in this case which is why you see "module is undefined")
%APPDATA%/npm/grunt.cmd
An alternative to using "grunt.cmd" is to use grunter which simply renames the command to grunter... then you no longer have this problem.
To answer this, first we need to understand that the error is caused because it is being executed by Windows Script Host.
Now, run the code from your cmd promt with the following syntax:
>node <application_name>.js
this will allow the Node.js application to open through V8 JavaScript engine(Google's).
P.S: Please reply back if this has helped in resolving your issue else post the problem you are facing after trying this.
I had a similar issue, the problem is file association, I would recommend:
right click on a .js file and choose open with.
then you choose nodejs/node.exe (somewhere in "program files" folder
then make tick box where it says "always open .js files " (paraphrasing)
That should do the trick.
I went through the same issue when running an old Node project.
The issue was with the name of the js file, it was node.js. So the while running the command node node.js, it was opening up a windows dialogue box.
I just changed the name of the file to app.js and the error flew away.
So, in my case i had tryed all the mentioned above with no result.
But i have fund that im dont type: node in the full sentence as the following snipet
node script.js.And remember never understimate your own miscoding.
Solution:
Go to any javascript file with "js" extension. (any file)
Right-Click(mouse) > Properties > "Opens with:" Change...(button)
Choose Notepad ( or any Javascript IDE like VS Code ).

Resources