npm run error react js - node.js

I am learning ReactJS. The installation has been done but when I run this npm command, I get the following error.
me#R-SOFT-85:/var/www/reactjsbasics$ npm run build
> reactjsbasics#1.0.0 build /var/www/reactjsbasics
> webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --watch
/var/www/reactjsbasics/node_modules/webpack/bin/convert-argv.js:487
throw new Error("'output.filename' is required, either in config file or as --output-filename");
^
Error: 'output.filename' is required, either in config file or as --output-filename
at processOptions (/var/www/reactjsbasics/node_modules/webpack/bin/convert-argv.js:487:11)
at processConfiguredOptions (/var/www/reactjsbasics/node_modules/webpack/bin/convert-argv.js:136:4)
at module.exports (/var/www/reactjsbasics/node_modules/webpack/bin/convert-argv.js:112:10)
at Object.<anonymous> (/var/www/reactjsbasics/node_modules/webpack/bin/webpack.js:155:40)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactjsbasics#1.0.0 build: `webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --watch`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactjsbasics#1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
┌──────────────────────────────────────────────────────────┐
│ npm update check failed │
│ Try running with sudo or get access │
│ to the local update config store via │
│ sudo chown -R $USER:$(id -gn $USER) /home/me/.config │
└──────────────────────────────────────────────────────────┘
npm ERR! A complete log of this run can be found in:
npm ERR! /home/me/.npm/_logs/2017-07-18T06_15_33_602Z-debug.log
webpack.config.js
var webpack=require("webpack");
var path=require("path");
var DIST_DIR = path.resolve(__dirname,"dist");
var SRC_DIR = path.resolve(__dirname,"src");
var config={
entry:SRC_DIR + "/app/index.js",
output:{
path:DIST_DIR+"/app",
filename:"bundle.js",
publicPath:"/app/"
},
module:{
loaders:[
{
test:"/\.js?/",
include:SRC_DIR,
loader:"babel-loader",
query:{
presets:["react","es2015","stage-2"]
}
}
]
}
};
package.json
"scripts": {
"start":"npm run build",
"build":"webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --watch",
"build:prod":"webpack -p && cp src/index.html dist/index.html"
},

It looks like you have forgotten to export your config
// webpack.config.js
var config = {
...
};
// you need to export config object
module.exports = config

Related

Why 'npm start' does not run the project in a browser with Node server.js at port :::3131 ? (JavaScript project)

I have a project written in JS around month ago. Since that time I didn't touch it.Now I wanna run the project again.
But when I type in Gitbash 'npm start' it's not opening the project in a browser.
It stucks at: 'node server.js' and doesn't go further.
Yesterday I had a problem with port 3131 where the project was deployed. I got information, the port was busy. So I used the 'netstat' command in CMD (windows) to find all open ports and then used 'taskkill' to terminate listening to port 3131.
But even after killing listening to that port, effect of 'npm start' was the same as today.
And it is happening with all my previous projects now. All of them where written during my online coding course in online coding School. I have finished it around a month ago.
Can it influence somehow at the issue with port 3131? Maybe I should change the port?
Important info: the project was deployed to Heroku, but couldn't work there. But even after deploying to Heroku 'npm start' was able to run project in the browser (a month ago).
BTW, 'npm run' looks like working fine, it runs all test etc.
Here is my package.json:
{
"name": "fer-07-project",
"version": "1.0.0",
"description": "",
"main": "index.html",
"scripts": {
"lint": "eslint --fix --ext .js,.jsx .",
"init-project": "npm install && npm-run-all init:*",
"init:dirs": "mkdirp dist src/sass src/css src/vendor src/images src/js",
"init:files": "touch README.md src/index.html src/sass/style.scss src/js/script.js",
"init:gitignore": "curl https://raw.githubusercontent.com/github/gitignore/master/Node.gitignore -o .gitignore",
"init:gitignore:custom": "echo \"dist\" >> .gitignore",
"test": "npm-run-all test:*",
"test:html": "globstar nu-html-checker dist/*.html",
"test:js": "eslint src/js/ --fix",
"test:scss": "stylelint src/sass/",
"build": "npm-run-all build:* test",
"build:clean": "mkdirp dist && rm -r dist && mkdirp dist",
"build:copy": "copyfiles -a -u 1 -e \"**/sass/**/*\" -e \"**/.gitkeep\" \"src/**/*\" dist",
"build:sass": "node-sass --output-style compact -o dist/css src/sass",
"build:autoprefixer": "globstar autoprefixer-cli \"dist/css/*.css\"",
"build-dev": "npm-run-all build-dev:sass build:autoprefixer",
"build-dev:sass": "node-sass --output-style expanded --source-map true -o dist/css src/sass",
"server": "json-server --port 3131 --no-cors --delay 250 --watch dist/db/app.json",
"watch": "npm-run-all build build-dev -p watch:* server",
"watch:browsersync": "browser-sync start --server dist --files \"dist/**/*\" --ignore \"dist/db/**/*\"",
"watch:sassprefixer": "onchange \"src/sass/**/*.scss\" -- npm run build-dev",
"watch:copy": "onchange -e \"**/sass/**/*\" -e \"**/.gitkeep\" \"src/**/*\" -- copyfiles -a -u 1 {{changed}} dist"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"flatpickr": "^4.6.9",
"json-server": "^0.16.3",
"rangeslider-pure": "^0.4.11"
},
"devDependencies": {
"autoprefixer-cli": "^1.0.0",
"browser-sync": "^2.26.3",
"copyfiles": "^2.1.0",
"eslint": "^5.14.1",
"globstar": "^1.0.0",
"mkdirp": "^0.5.1",
"node-sass": "^4.11.0",
"npm-run-all": "^4.1.5",
"nu-html-checker": "^0.1.0",
"onchange": "^5.2.0",
"stylelint": "^9.10.1",
"stylelint-scss": "^3.5.4"
}
}
AND server.js:
/* global require, process */
const jsonServer = require('json-server');
const server = jsonServer.create();
const router = jsonServer.router('dist/db/app.json');
const middlewares = jsonServer.defaults({
static: 'dist',
noCors: true
});
const port = process.env.PORT || 3131;
server.use(middlewares);
server.use(router);
server.listen(port);
HERE IS AN ISSUE IN GITBASH WHEN STARTING ANOTHER PROJECT WITH 'YARN START'
$ yarn start
yarn run v1.22.10
$ npm-run-all -p server:*
$ node server.js
$ webpack-dev-server --mode development --open --hot
events.js:292
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3131
at Server.setupListenHandle [as _listen2] (net.js:1318:16)
at listenInCluster (net.js:1366:12)
at Server.listen (net.js:1452:7)
at Function.listen (C:\Users\kpych.LENOVO-KP\OneDrive\Pulpit\Nowy folder (4)\Project-12_Travel_agency\node_modules\express\lib\application.js:618:24)
at Object.<anonymous> (C:\Users\kpych.LENOVO-KP\OneDrive\Pulpit\Nowy folder (4)\Project-12_Travel_agency\server.js:32:10)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1345:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'EADDRINUSE',
errno: -4091,
syscall: 'listen',
address: '::',
port: 3131
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: "server:api" exited with 1.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Gitbash npm start

BABEL_PARSE_ERROR when deploying Nodejs app on heroku

I am deploying node js application on heroku server. I am using webpack for es6 syntax and its working fine everything on my local.
But when I am trying to deploy code on heroku it gives BABEL_PARSE_ERROR.
remote: > taleem-backend#1.0.0 build /tmp/build_dbe1f098c9b56734350ccb6e4f4c0166
remote: > rimraf dist/ && babel ./ --out-dir dist
remote:
remote: SyntaxError: /tmp/build_dbe1f098c9b56734350ccb6e4f4c0166/.heroku/node/lib/node_modules/npm/docs/gatsby-browser.js: Unexpected token (7:9)
remote:
remote: 5 |
remote: 6 | export const wrapPageElement = ({ element, props }) => {
remote: > 7 | return <Layout {...props} >{element}</Layout>
remote: | ^
remote: 8 | }
remote: 9 |
remote: at Parser.raise (/tmp/build_dbe1f098c9b56734350ccb6e4f4c0166/node_modules/#babel/parser/lib/index.js:7017:17)
remote: at Parser.unexpected (/tmp/build_dbe1f098c9b56734350ccb6e4f4c0166/node_modules/#babel/parser/lib/index.js:8395:16)
remote: at Parser.parseExprAtom (/tmp/build_dbe1f098c9b56734350ccb6e4f4c0166/node_modules/#babel/parser/lib/index.js:9673:20)
remote: at Parser.parseExprSubscripts (/tmp/build_dbe1f098c9b56734350ccb6e4f4c0166/node_modules/#babel/parser/lib/index.js:9259:23)
remote: at Parser.parseMaybeUnary (/tmp/build_dbe1f098c9b56734350ccb6e4f4c0166/node_modules/#babel/parser/lib/index.js:9239:21)
remote: at Parser.parseExprOps (/tmp/build_dbe1f098c9b56734350ccb6e4f4c0166/node_modules/#babel/parser/lib/index.js:9109:23)
remote: at Parser.parseMaybeConditional (/tmp/build_dbe1f098c9b56734350ccb6e4f4c0166/node_modules/#babel/parser/lib/index.js:9082:23)
remote: at Parser.parseMaybeAssign (/tmp/build_dbe1f098c9b56734350ccb6e4f4c0166/node_modules/#babel/parser/lib/index.js:9037:21)
remote: at Parser.parseExpression (/tmp/build_dbe1f098c9b56734350ccb6e4f4c0166/node_modules/#babel/parser/lib/index.js:8989:23)
remote: at Parser.parseReturnStatement (/tmp/build_dbe1f098c9b56734350ccb6e4f4c0166/node_modules/#babel/parser/lib/index.js:11057:28) {
remote: pos: 209,
remote: loc: Position { line: 7, column: 9 },
remote: code: 'BABEL_PARSE_ERROR'
remote: }
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! taleem-backend#1.0.0 build: `rimraf dist/ && babel ./ --out-dir dist`
remote: npm ERR! Exit status 1
Above error is coming in node_modules, but I am already ignoring my node_modules in webpack.config.js and I double check its working fine in my local (ignore logic)
heroku local web
I run above command as its mentioned in heroku docs and
its also working fine
https://devcenter.heroku.com/articles/deploying-nodejs
But when I run
git push heroku master
I got above error. Kindly help me on this to fix this issue.
Thanks
EDIT
webpack.config.js
module.exports = (api) => {
api.cache(true)
return {
ignore: [
"babel.config.js",
"dist",
"package.json",
"node_modules",
'.babelrc'
]
}
}
package.json
"scripts": {
"start": "npm run build && node dist/bin/www",
"build": "rimraf dist/ && babel ./ --out-dir dist",
"watch:dev": "nodemon"
},
Now I fixed that by updating app structure
"build": "rimraf dist/ && babel app/ --out-dir dist",

How to solve Node.js Error: Cannot find Module?

When I start a dockerized Node.js testapp with
sudo docker-compose up
I get the following error:
Starting testapp_web_1 ... done
Attaching to testapp_web_1
web_1 |
web_1 | > testapp#0.0.1 start /usr/app
web_1 | > node index.js
web_1 |
web_1 | internal/modules/cjs/loader.js:613
web_1 | throw err;
web_1 | ^
web_1 |
web_1 | Error: Cannot find module 'mongodb'
web_1 | Require stack:
web_1 | - /usr/app/index.js
web_1 | at Function.Module._resolveFilename (internal/modules/cjs/loader.js:610:15)
web_1 | at Function.Module._load (internal/modules/cjs/loader.js:526:27)
web_1 | at Module.require (internal/modules/cjs/loader.js:666:19)
web_1 | at require (internal/modules/cjs/helpers.js:16:16)
web_1 | at Object.<anonymous> (/usr/app/index.js:4:21)
web_1 | at Module._compile (internal/modules/cjs/loader.js:759:30)
web_1 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
web_1 | at Module.load (internal/modules/cjs/loader.js:628:32)
web_1 | at Function.Module._load (internal/modules/cjs/loader.js:555:12)
web_1 | at Function.Module.runMain (internal/modules/cjs/loader.js:826:10)
web_1 | npm ERR! code ELIFECYCLE
web_1 | npm ERR! errno 1
web_1 | npm ERR! testapp#0.0.1 start: `node index.js`
web_1 | npm ERR! Exit status 1
web_1 | npm ERR!
web_1 | npm ERR! Failed at the testapp#0.0.1 start script.
web_1 | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
web_1 |
web_1 | npm ERR! A complete log of this run can be found in:
web_1 | npm ERR! /root/.npm/_logs/2019-05-04T15_34_04_615Z-debug.log
testapp_web_1 exited with code 1
The project structur is as follows
- testapp
--- docker-compose.yml
--- dockerfile
--- src
----- index.js
----- package.json
index.js
'use strict';
const MongoClient = require('mongodb').MongoClient;
const express = require('express');
// Constants
const PORT = 8080;
// App
const app = express();
app.get('/', (req, res) => {
res.send('Hello world\n');
});
app.listen(PORT);
console.log(`Running on Port:${PORT}`);
package.json
{
"name": "testapp",
"version": "0.0.1",
"description": "Testapp",
"author": "hi there",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"express": "^4.16.4",
"mongodb": "^3.2.3"
}
}
dockerfile
FROM node:12-alpine
WORKDIR /usr/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 8080
docker-compose.yml
version: '3'
services:
web:
build: .
command: npm start
volumes:
- ./src:/usr/app/
- /usr/app/node_modules
ports:
- 80:8080
I have alread read this stackoverflow thread but I couldn't solve this issue. I'm getting this error no matter what module I'm trying to use: mongodb, spdy, etc. Locally without docker the testapp is working. But I don't know what I'm doing wrong with docker. Can anyone help me?
Have volume folder mapping for node_modules and ensure it has mongo folder copied / created
version: '3'
services:
web:
build: .
command: npm start
volumes:
- ./src:/usr/app/
- ./src/node_modules:/usr/app/node_modules
ports:
- 80:8080
Ref:https://morioh.com/p/42531a398049/containerizing-a-node-js-application-for-development-with-docker-compose
You need to drop & rebuild the anonymous volume holding the node_modules for the updates to package.json to take effect.
docker-compose rm -v
# then:
docker-compose build
docker-compose up
You will only have to do this for changes to node_modules, since the other volume is linked to your ./src/, and will reflect changes on the host.

Node/Webpack on Laravel is going Bonkers

I have been compiling my project for many months now and it has never been an issue. I was coding for most of today with npm run watch on. Then suddenly it stop compiling CSS, watch was still running but CSS was not updating.
A commit to Bitbucket reveals the following:
public/mix-manifest.json
{
- "/js/app.js": "/js/app.js",
- "/css/app.css": "/css/app.css"
+ "/js/app.js": "/js/app.js"
}
The app.css has been removed?
public/js/app.js
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
-/******/ if(installedModules[moduleId]) {
+/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
-/******/ }
+/******/
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
...
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
-/* WEBPACK VAR INJECTION */(function($) {/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__components_passwordValidator__ = __webpack_require__(9);
+/* WEBPACK VAR INJECTION */(function($) {Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
+/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__components_passwordValidator__ = __webpack_require__(9);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__components_passwordShowHide__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__components_selectComponent__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__components_showHideComponent__ = __webpack_require__(11);
...
/* 2 */
/***/ (function(module, exports) {
-// removed by extract-text-webpack-plugin
+throw new Error("Module build failed: ModuleNotFoundError: Module not found: Error: Can't resolve './images/dashboard-details-2.jpg' in 'F:\\openvisa-webapp\\resources\\assets\\sass'\n at factoryCallback (F:\\openvisa-webapp\\node_modules\\webpack\\lib\\Compilation.js:260:39)\n at F:\\openvisa-webapp\\node_modules\\webpack\\lib\\NormalModuleFactory.js:243:19\n at onDoneResolving (F:\\openvisa-webapp\\node_modules\\webpack\\lib\\NormalModuleFactory.js:59:20)\n at F:\\openvisa-webapp\\node_modules\\webpack\\lib\\NormalModuleFactory.js:132:20\n at F:\\openvisa-webapp\\node_modules\\webpack\\node_modules\\async\\dist\\async.js:3799:9\n at F:\\openvisa-webapp\\node_modules\\webpack\\node_modules\\async\\dist\\async.js:360:16\n at iteratorCallback (F:\\openvisa-webapp\\node_modules\\webpack\\node_modules\\async\\dist\\async.js:934:13)\n at F:\\openvisa-webapp\\node_modules\\webpack\\node_modules\\async\\dist\\async.js:844:16\n at F:\\openvisa-webapp\\node_modules\\webpack\\node_modules\\async\\dist\\async.js:3796:13\n at apply (F:\\openvisa-webapp\\node_modules\\webpack\\node_modules\\async\\dist\\async.js:21:25)\n at F:\\openvisa-webapp\\node_modules\\webpack\\node_modules\\async\\dist\\async.js:56:12\n at F:\\openvisa-webapp\\node_modules\\webpack\\lib\\NormalModuleFactory.js:124:22\n at onResolved (F:\\openvisa-webapp\\node_modules\\enhanced-resolve\\lib\\Resolver.js:70:11)\n at loggingCallbackWrapper (F:\\openvisa-webapp\\node_modules\\enhanced-resolve\\lib\\createInnerCallback.js:31:19)\n at afterInnerCallback (F:\\openvisa-webapp\\node_modules\\enhanced-resolve\\lib\\Resolver.js:138:10)\n at loggingCallbackWrapper (F:\\openvisa-webapp\\node_modules\\enhanced-resolve\\lib\\createInnerCallback.js:31:19)\n at Resolver.applyPluginsAsyncSeriesBailResult1 (F:\\openvisa-webapp\\node_modules\\tapable\\lib\\Tapable.js:181:46)\n at innerCallback (F:\\openvisa-webapp\\node_modules\\enhanced-resolve\\lib\\Resolver.js:125:19)\n at loggingCallbackWrapper (F:\\openvisa-webapp\\node_modules\\enhanced-resolve\\lib\\createInnerCallback.js:31:19)\n at F:\\openvisa-webapp\\node_modules\\tapable\\lib\\Tapable.js:283:15\n at F:\\openvisa-webapp\\node_modules\\enhanced-resolve\\lib\\UnsafeCachePlugin.js:38:4\n at loggingCallbackWrapper (F:\\openvisa-webapp\\node_modules\\enhanced-resolve\\lib\\createInnerCallback.js:31:19)\n at afterInnerCallback (F:\\openvisa-webapp\\node_modules\\enhanced-resolve\\lib\\Resolver.js:138:10)\n at loggingCallbackWrapper (F:\\openvisa-webapp\\node_modules\\enhanced-resolve\\lib\\createInnerCallback.js:31:19)\n at Resolver.applyPluginsAsyncSeriesBailResult1 (F:\\openvisa-webapp\\node_modules\\tapable\\lib\\Tapable.js:181:46)\n at innerCallback (F:\\openvisa-webapp\\node_modules\\enhanced-resolve\\lib\\Resolver.js:125:19)\n at loggingCallbackWrapper (F:\\openvisa-webapp\\node_modules\\enhanced-resolve\\lib\\createInnerCallback.js:31:19)\n at F:\\openvisa-webapp\\node_modules\\tapable\\lib\\Tapable.js:283:15\n at innerCallback (F:\\openvisa-webapp\\node_modules\\enhanced-resolve\\lib\\Resolver.js:123:11)\n at loggingCallbackWrapper (F:\\openvisa-webapp\\node_modules\\enhanced-resolve\\lib\\createInnerCallback.js:31:19)");
/***/ }),
/* 3 */
I've tried putting configuring the public/mix-manifest.json back to the way it was:
public/mix-manifest.json
{
"/js/app.js": "/js/app.js",
"/css/app.css": "/css/app.css"
}
Run npm run watch or npm run dev and it will just remove the "/css/app.css": "/css/app.css"
public/mix-manifest.json
{
-"/js/app.js": "/js/app.js",
-"/css/app.css": "/css/app.css"
+"/js/app.js": "/js/app.js"
}
The Node Error that I get after running npm run dev is:
npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Cory\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
npm ERR! node v6.11.1
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! # dev: `node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the # dev script 'node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! F:\openvisa-webapp\npm-debug.log
Please note I don't get this error when running npm run watch it just doesn't compile CSS, this Error only comes up on npm run dev. But neitherless the error is still there on watch.
I have no idea how to fix it. I've tried npm install, but nothing works.
Issue has been resolved. This will happen if your CSS background images don't have a correct path.

Cannot find module 'ibmbluemix' on starting application on ibm cloud

I start recently my first nodeJs application on IBM blumix, in following these tutorial http://ibm-bluemix.coderpower.com/#/warmup/55e07bf49924f792327901cd/code.
i following the instruction but when I start my application I have the error Cannot find module 'ibmbluemix'
I have the same code as the tutorial, I almost feel that the ibm bluemix module is not installed ... on the cloud ibm bluemix.
Here is the code
package.json
{
"name": "NodejsStarterApp",
"version": "0.0.1",
"description": "A sample nodejs app for Bluemix",
"scripts": {
"start": "node app.js"
},
"dependencies": {
"express": "4.12.x",
"cfenv": "1.0.x"
},
"repository": {},
"engines": {
"node": "0.12.x"
}
}
app.js
var express = require('express');
var ibmbluemix = require('ibmbluemix');
var config = {
applicationId:"FirstAppli",
applicationRoute:"firstappli.mybluemix.net"
};
// cfenv provides access to your Cloud Foundry environment
// for more info, see: https://www.npmjs.com/package/cfenv
var cfenv = require('cfenv');
// create a new express server
var app = express();
// serve the files out of ./public as our main files
app.use(express.static(__dirname + '/public'));
var router = express.Router();
router.get('/', /* #callback */ function(req,res){
ibmbluemix.initialize(config).then(/* #callback */ function(success) {
res.json({ message : 'sdk initialised' });
},
/* #callback */ function(err){
res.json({ message : 'sdk error' });
});
});
app.use('/api', router);
// get the app environment from Cloud Foundry
var appEnv = cfenv.getAppEnv();
// start server on the specified port and binding host
app.listen(appEnv.port, '0.0.0.0', function() {
// print a message when the server starts listening
console.log("server starting on " + appEnv.url);
});
the log on starting
Starting app instance (index 0) with guid 8a0df22f-7c18-476f-8dc0-91c3db946ac6
Updated app with guid 8a0df22f-7c18-476f-8dc0-91c3db946ac6 ({"state"=>"STARTED"})
Detected 1024 MB available memory, 512 MB limit per process (WEB_MEMORY)
Recommending WEB_CONCURRENCY=2
Activating app management utilities: devconsole, shell, inspector
2015/10/27 10:46:52 authenticator url is detected as https://api.ng.bluemix.net/v2/apps/8a0df22f-7c18-476f-8dc0-91c3db946ac6/env
2015/10/27 10:46:52 The application base path is detected as /home/vcap
2015/10/27 10:46:52 Starting the proxy agent on port 61392
2015/10/27 10:46:52 Begin to start the runtime...
Starting utility: devconsole...
Adding proxy entry with: {"type": "http-forward", "backend": "127.0.0.1:8788", "host": "*", "uri_prefix": "bluemix-debug/manage"}
2015/10/27 10:46:52 Catch event "/home/vcap/app/.app-management/bin/proxy.config": WRITE. Reload the registry.
Starting utility: shell...
Adding proxy entry with: {"type": "http-forward", "backend": "127.0.0.1:8789", "host": "*", "uri_prefix": "bluemix-debug/shell"}
2015/10/27 10:46:52 Catch event "/home/vcap/app/.app-management/bin/proxy.config": WRITE. Reload the registry.
Starting utility: inspector...
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 1132 828 ? S<s 10:46 0:00 wshd: 192t1kppgo2
vcap 29 0.0 0.0 270040 5408 ? S<sl 10:46 0:00 .app-management/bin/proxyAgent
vcap 35 0.0 0.0 19592 3452 ? S< 10:46 0:00 bash /home/vcap/app/.app-management/handlers/start-inspector/run
vcap 45 0.0 0.0 19596 3408 ? S< 10:46 0:00 bash /home/vcap/app/.app-management/scripts/start 61393
vcap 72 0.0 0.0 677992 25228 ? R<l 10:46 0:00 /home/vcap/app/.app-management/node/bin/node bin/dev.js bluemix-debug/manage 8788
vcap 88 0.0 0.0 677992 23480 ? R<l 10:46 0:00 npm
vcap 113 0.0 0.0 611432 20688 ? R<l 10:46 0:00 /home/vcap/app/.app-management/node/bin/node server.js bluemix-debug/shell 8789
vcap 145 0.0 0.0 19588 292 ? R< 10:46 0:00 bash /home/vcap/app/.app-management/handlers/start-inspector/run
vcap 146 0.0 0.0 17172 2472 ? R< 10:46 0:00 ps aux
Adding proxy entry with: {"type": "http-forward", "backend": "127.0.0.1:8790", "host": "*", "uri_prefix": "bluemix-debug/inspector"}
2015/10/27 10:46:52 Catch event "/home/vcap/app/.app-management/bin/proxy.config": WRITE. Reload the registry.
> NodejsStarterApp#0.0.1 start /home/vcap/app
> node app.js
node-inspector is active. Visit the web page to start debugging.
module.js:338
throw err;
^
Error: Cannot find module 'ibmbluemix'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/vcap/app/app.js:11:18)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
npm ERR! Linux 3.19.0-25-generic
npm ERR! argv "/home/vcap/app/vendor/node/bin/node" "/home/vcap/app/vendor/node/bin/npm" "start"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! code ELIFECYCLE
npm ERR! NodejsStarterApp#0.0.1 start: `node app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the NodejsStarterApp#0.0.1 start script 'node app.js'.
npm ERR! This is most likely a problem with the NodejsStarterApp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node app.js
npm ERR! You can get their info via:
npm ERR! npm owner ls NodejsStarterApp
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/vcap/app/npm-debug.log
2015/10/27 10:46:53 Fail to start the application runtime: The runtime cannot be started. Error: Runtime start script returns error 'exit status 1'. Please check the application logs for more details.
Restarting the runtime in debug mode...
scripts/stop: line 27: kill: (88) - No such process
kill -9 88
scripts/stop: line 32: kill: (88) - No such process
Starting app with 'node --debug=5858 app.js '
Debugger listening on port 5858
module.js:338
throw err;
^
Error: Cannot find module 'ibmbluemix'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/vcap/app/app.js:11:18)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
firstappli.mybluemix.net - [27/10/2015:11:01:33 +0000] "GET /bluemix-debug/manage/tools/runtime HTTP/1.1" 200 0 69 "-" "Jakarta Commons-HttpClient/3.1" 108.168.250.153:11163 x_forwarded_for:"198.11.229.213" vcap_request_id:2ce77b66-4cc0-403d-6558-a020a23e4b93 response_time:0.259158396 app_id:8a0df22f-7c18-476f-8dc0-91c3db946ac6
I don't understand, I've not tried to test the code in local but i'm surprise that nobody on internet had the same error that me. Maybe I have forgotten something obvious... Thanks for your help!
PS : I have not use the default space created but I create a new one (otherwise I cant't create node application), maybe there is some repercussion...
You need to add ibmbluemix as a dependency in your package.json file:
{
"name": "NodejsStarterApp",
"version": "0.0.1",
"description": "A sample nodejs app for Bluemix",
"scripts": {
"start": "node app.js"
},
"dependencies": {
"express": "4.12.x",
"cfenv": "1.0.x",
"ibmbluemix": "1.0.0"
},
"repository": {},
"engines": {
"node": "0.12.x"
}
}
If you want to try your application locally run the following commands after changing package.json file:
# npm install
# node app.js

Resources