appfog is unable to install node.js application - node.js

I can't get my node.js application to work on appfog. I create a new application on their website. Then in my application directory i run:
af login <-- Works
and then:
af update myapplicationname
I get this error: No such file or directory - /Users/Name/myapplicationname/node_modules/bower
I don't use bower. I tryed use bower but i removed it and the files.
My package.json looks like this:
{
"name": "myapplicationname",
"description": "My application",
"version": "0.0.1",
"private": true,
"dependencies": {
"express": "3.x"
}
}
I user version 0.8.14 of node which should be supported by appfog.
What am i missing here?

I run into the following and managed to fix it by:
1) removing the node_modules folder (rm -rf node_modules)
2) reinstall all the dependencies (npm install)
3) recreate the shrinkwrap.json (npm shrinkwrap)

Related

I cannot create a react app with npx create-react-app

Whenever I try to create a react app with npx create-react-app I get a folder with a single file in it along with the message "Missing dependencies in package.json."
The contents of package.json, the one file in the folder, s:
{
"name": "plzwurk",
"version": "0.1.0",
"private": true
}
npm version:8.19.2
node version: v18.12.1
How can I fix this?
I have fully uninstalled npm and node. I tried different versions, restarting my system, and everything else I could find.

NodeJS installed modules are not recognized on Windows 10

I need some help to setup NodeJS on a Windows 10 machine.
I installed the 10.15.3 LTS version from the official website which has done the following:
Node installed at C:\Program Files\nodejs\
Added to the Path in the user's variables: C:\Users\rsantos\AppData\Roaming\npm
Added to the Path in the environment variables: C:\Program Files\nodejs\
Created an empty npm folder at: C:\Users\rsantos\AppData\Roaming
Then with npm init I initialized the package file which was created at C:\Users\rsantos.
Followed by npm install supervisor which:
Created a npm-cache folder at C:\Users\rsantos\AppData\Roaming\npm-cache
Created a node_modules folder (with the supervisor) at C:\Users\rsantos\node_modules
Created a package-lock.json file at C:\Users\rsantos with:
{
"name": "rsantos",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"supervisor": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/supervisor/-/supervisor-0.12.0.tgz",
"integrity": "sha1-3n5jNwFbKRhRwQ81OMSn8EkX7ME="
}
}
}
Updated the package.json file to:
{
"name": "rsantos",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"supervisor": "^0.12.0"
}
}
Then when I open the command line and type:
C:\Users\rsantos\Desktop>supervisor --watch C:\NodeJS_Projects\Proj1\ -e js C:\NodeJS_Projects\Proj1\Test.js
I get:
'supervisor' is not recognized as an internal or external command, operable program or batch file.
After that I tried to install supervisor globally and it started to work.
The next error was 'require' not being recognized after installed locally.
I followed the same approach which made supervisor work and installed require globally. My code is requiring the module with require('request'). But even installed globally, it fails with this error:
Error: Cannot find module 'request' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
Notes:
I uninstalled everything and reinstalled, the result was always the same.
Also played with the environment variables but still no good.
npm list -g request outputs this: C:\Users\rsantos\AppData\Roaming\npm -- request#2.88.0
At this point my C:\Users\rsantos\node_modules folder has all the modules, including supervisor and request.
The package.json has supervisor and request as dependencies.
The package-lock.json seems to have all the modules in the node_modules folder, including supervisor and request.
I still get the Cannot find module 'request' error.
Can someone help please?
when you want to use a NPM package as tool (e.g. >supervisor --watch PATH), you can install the package --global. When you want to load the package in Node with require() I would install it locally.
Does the following work for you?
Install the tooling globally:
npm install --global supervisor
Set up your project in local folder:
mkdir project
cd project
npm init -y
npm install --save request # install to project/node_modules
node index.js # start your app

Cannot install vue

I usually perform fresh re-installs of packages after a period of non-use, but when I came to perform a fresh install of Vue.js and vue-cli I tried to perform a vue init on a new project but was told that vue was not recognised as an operable or batch file etc.
It is possible that I created a problem when I uninstalled vue-cli, which removed something like 250 packages. Subsequent reinstall only installed 1 package, but I was then unable to get any response from the vue init command other than the above.
I have tried every workaround I could find on SO and elsewhere which boils down to the following: -
Upgrading node and npm
Upgrading git
Cleaning the npm cache
One consistent error message in my attempts to perform npm install vue was that I lacked a package.json file in my C:/Users/user folder (I am said user and I have administrator privileges). I ran npm init to create a blank package.json file in that folder but that didn't work either.
The root problem seems to be that nothing I do re-installs a vue.cmd file in my AppData/Roaming/npm folder, even though this path is properly installed in my environment variables. I have looked if this file has been installed elsewhere on my machine, but it hasn't.
Is it possible to manually download a vue.cmd file and put it exactly where it needs to sit, i.e. in my AppData/Roaming/npm folder? I googled this to no avail. All this is while running Command Prompt as an administrator.
Is anyone else having this problem? Is there something with another JS framework which is currently blocking Vue from being properly installed? (I have also developed projects in React and Angular5.)
Just as an update, this is the package.json file I currently have in my C:/Users/user folder after running npm init from that folder: -
{
"name": "user",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"npm": "^5.8.0",
"vue": "^2.5.16"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
It sounds like you don't have vue-cli installed on your machine
But without any error messages it's impossible to tell.
try npm install -g vue-cli#2.9.3
then run which vue-cli to check the location

node local dependency installs as shortcut and nested instead of flat

It seems this started when I updated node/npm but I didn't realized until now when I had to delete and re create my node_modules folder.
I have a React Native project which has the core module and one Examples project to showcase the module. The examples project references the module like this in my package.json:
"dependencies": {
"module-core": "file:../core"
},
When I run npm install in the Examples project I was getting this nodule_module structure:
node_modules
core
core_dependency_1
core_dependency_2
Now, I get this:
node_modules
core
node_modules
core_dependency_1
core_dependency_2
At first I thought it had to do with peerDepencies and how npm handled flat/nested dependencies but I have checked and it seems now the core folder is now a shortcut (I am using Windows).
This is breaking my gradle scripts because some are referenced like this:
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
I could fix this by renaming the links but that would make the build platform/environment dependent.
Also it breaks some other scripts like this one:
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
That is because the project() resolves to my root folder and now I cannot use that either.
I am using npm 5.4.2 and node 8.8.1. Previously I had node 7.4.0.
Is there any flag or way to make npm install the localDependency and not treat it as a shortcut?
I finally found the answer. Npm Version 5 indeed changed the way the local dependencies are handled and it just makes npm link, which creates symbolic links or shortcuts in windows.
You can accomplish the same behavior as before with this:
npm install $(npm pack <folder> | tail -1)
Working for me in Windows 10 with git-bash
My final solution was having this package.json in the Example project that used the core:
{
"name": "core-examples",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"preinstall": "npm pack ../Core | tail -1",
},
"dependencies": {
"core": "file:core-0.0.0.tgz"
},
"jest": {
"preset": "react-native"
}
}
The preinstall script will generate the tgz file and then you can install as usual. This will avoid having to commit the tgz file to the repository.

Nothing happen with bower install

I'm trying to setup angular app with yeoman, following this steps: http://yeoman.io/
Everything works fine until I do
grunt test
I got
Chrome 24.0.1312 (Linux) ERROR
Uncaught ReferenceError: angular is not defined
at /var/www/moviz-test/app/scripts/app.js:3
Chrome 24.0.1312 (Linux) ERROR
Uncaught ReferenceError: angular is not defined
at /var/www/moviz-test/app/scripts/controllers/main.js:3
It's because bower install do nothing, I don't have the folder app/bower_components
.bowerrc
{
"directory": "app/bower_components"
}
bower.json
{
"name": "myApp",
"version": "0.0.0",
"dependencies": {
"angular": "~1.0.7",
"json3": "~3.2.4",
"jquery": "~1.9.1",
"bootstrap-sass": "~2.3.1",
"es5-shim": "~2.0.8",
"angular-resource": "~1.0.7",
"angular-cookies": "~1.0.7",
"angular-sanitize": "~1.0.7"
},
"devDependencies": {
"angular-mocks": "~1.0.7",
"angular-scenario": "~1.0.7"
}
}
I've uninstall and reinstall bower and nothing change
bower -v 1.2.3
node -v v0.10.17
This happened to me as well. The reason was that I was following old tutorial that said bower's package file was components.json instead of bower.json. So bower was looking for later and as it couldn't find file it would just say nothing (it should actually show warning or error). When I renamed file to bower.json it all worked.
I couldn't install newest ember package because bower install did nothing, but:
cd bower_components
rm -rf package-name
now bower install
helped.

Resources