can not setup ReactJS on mac - node.js

I need to setup ReactJS on my Mac. I have npm version of 4.1.2 and node version of v7.7.4. I clone the project from Git and in the project folder trying to execute npm install and following npm start. But I get error.
I removed&uninstalled node and npm and then re-installed with homebrew, but it did not help. Here is the screen of error I get in terminal? Do you have any idea what is the problem?
Here is my package.json file
{
"name": "viaopt",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {},
"devDependencies": {
"webpack": "^2.3.0"
},
"description": ""
}

From the error you are showing I can tell that there is no start script in your package.json file. For npm start to work there should be a command under the start key under the scripts attribute in your package.json file.
When you run npm start npm looks in package.json and runs whatever is listed there under the start value.
I'm guessing you have gulp or webpack configured with your project?
Try running webpack in your terminal and see if your project fires up or smth.
Hopes this helps.
Cheers.

If your trying to setup a new React App you can use
Create React App. It will setup React / Webpack for you.

Related

Npm ERR! Line breaks can’t be quoted on Windows

i have the following package.json code:
{
"name": "pre-post",
"version": "1.0.0",
"description": "",
"main": "basic-server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"ignore": "echo \"\" >> .gitignore",
"preignore": "touch .gitignore",
"postignore": "echo \".gitignore\n.vscode/\nnode_modules/\" >> .gitignore"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"linebreak": "^1.0.2",
"open": "^7.4.0"
}
}
after i run in node js command, i have the error message of npm ERR! Line breaks can't be quoted on Windows, any fix?
Check whether your package.json have swiper
There are 4 steps to solve this problem
Remove "swiper" : "^5.4.5" from package.json file.(Check there should be no comma in last line of your json file)
Run npm install command in your terminal.
Run npm install swiper command.
Now you will see everything has been installed successfully.
Just don't install it from Git Bash on Windows. Use cmd.exe and it works as a charm !
Uninstall node.js from Control Panel/Programs
Download fresh node.js installer and install them.
(important) reboot system.
I face the same problem and this thing is work for me
Uninstall node completely use this answer
reboot your device
download again from official website
Use yarn to install the dependencies. Solved for me.

Unable to get grunt to run any task

Very new to this, sorry.
I'm running node.js v6.9.5 npm 4.2.0.
Installed grunt-cli on Windows 10.
And this is where I think I've gone wrong, I did npm install -g grunt-init which has created a node_modules folder in C:\User[my name]\AppDate\Roaming directory.
I've since uninstalled this using npm uninstall grunt --save.
I created the following package.jason in my project root:
{
"name": "manifest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {},
"devDependencies": {
"grunt": "^1.0.1"
}
}
run npm install which created a new node_modules directory in my project root.
Create a Gruntfile.js containing the following:
module.exports = function(grunt) {
grunt.registerTask('speak', function() {
console.log('hello');
})
}
But when I run grunt speak I'm getting the message:
Loading "Gruntfile.js" tasks...ERROR
>> SyntaxError: Invalid or unexpected token
Warning: Task "speak" not found. Use --force to continue.
Aborted due to warnings.
What am I doing wrong please?
Ok, managed to get round this by totally uninstalling grunt, grunt-cli, npm and node.js, and reinstalling them all from scratch.

npm install does not install the dependencies of individual node modules into the respective node modules folders

npm install was installing node modules correctly until recently when I ran into a bug. Now, npm install does not install the dependencies of individual node modules into the respective node modules folders.
See screenshot for what I mean.
The finder window at the forefront shows the correct npm install before the bug. npm install express would download and put the files in correct folders. The accepts folder is a node module of express and has its own node modules, mime types and negotiator.
Now, the accepts folder and its own node modules sit out at the same level as express folder. As seen in the finder window in the back.
This is causing me not to be able to upload to heroku.
Please advise on how to fix.
Here's my package.json
{
"name": "node-muse-examples-webgui",
"version": "0.1.0",
"description": "An example on how to use the node-muse module in a web interface.",
"main": "index.js",
"engines": {
"node": "7.2.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/ShaPOC/node-muse/tree/master/examples/webgui"
},
"author": "Jimmy Aupperlee <j.aup.gt#gmail.com>",
"license": "GPLv3",
"dependencies": {
"body-parser": "^1.15.2",
"express": "^4.14.0",
"leapjs": "^0.6.4",
"mongodb": "^2.2.7",
"node-muse": "^0.1.0",
"socket.io": "^1.3.5"
}
}
That behavior is not a bug, it actually is a new behavior introduced with npm#3.
That normally should not cause any conflict or problems, but if it does in your case try to install it with
npm install --legacy-bundling
instead, so delete the whole node_modules folder and reinstall it with that command.

Refusing to install 'module' as a dependency of itself

Recently, I was playing with a gulp tutorial and had this error
Refusing to install gulp as a dependency of itself
when executing
npm install --save-dev gulp
what could be the issue?
The problem was in the name of my own application.
In package.json, I accidently named it gulp
{
"name": "gulp",
"version": "1.0.0",
"description": "tutorial",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "rmv",
"license": "ISC",
"devDependencies": {}
}
Make sure your app is not called as one of the dependencies you will be using.
This error occurs when you are trying to install the package from the path (or in the folder) in which you had created the package.. Just navigate to some other folder or path and then try to install the package It should work.

npm WARN install Refusing to install hapi as a dependency of itself

I tried to do the following (per instructions from official site):
mkdir hapi && cd hapi
npm init
npm install hapi --save
But this gives me an error like this:
npm WARN install Refusing to install hapi as a dependency of itself
Now, I made a new test folder called hapiTest and repeated the commands and then everything worked fine.
I tried the same process with a folder gulp and npm install gulp --save, and got the same error, so my conclusion is that I can't have the name of the folder be the same as the package that I want to install, but can someone back this statement up with some official documentation?
When you did the command npm init, there were probably some relevant questions you needed to answer. Specifically, the name of your module. When you use npm init, it assumes you want the name of the module you're creating to be called the name of the folder it is in.
So it's not the name of the folder that is stopping you from installing the dependency, it is the name of the npm module that you are creating.
Open the resulting package.json within your hapi directory, and rename the module to something other than hapi. Here's an example 'package.json' that works, even when residing in a folder called hapi:
{
"name": "hapi-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"hapi": "^7.5.2"
}
}
Added Note
I've not been able to find any documentation thus-far explaining this phenomena in the context of npm; though it is a bit of a no-brainer. Requiring modules with the same name within the same application would conflict with the CommonJS philosophy.
The name of your module is same as the module you are trying to install. NPM thinks that you are installing the module to itself. Change the name of your module and it will install perfectly.
Reason
Module name is same with library name
Solution
Change the module name to something else
Change 'name' in package.json
The issue can be simply explained as follows
the name of your package or module in package.json cannot be same as that of the package or module you are trying to install.
Here hapi is the name of your module and you are trying to install a module with name hapi with npm install hapi --save
This was my initial code
{
"name": "react",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"react": "^15.6.1"
}
}
which threw error
npm WARN package.json react#1.0.0 No description
npm WARN package.json react#1.0.0 No repository field.
npm WARN package.json react#1.0.0 No README data
npm WARN install Refusing to install react as a dependency of itself
then i renamed the name from react to react_app and my code looks like
{
"name": "react_app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"react": "^15.6.1"
}
}
then it worked

Resources