Nativescript-cli: Can't run npm build-ios-bundle and others script

Created on 16 Jun 2017  路  9Comments  路  Source: NativeScript/nativescript-cli

Did you verify this is a real problem by searching Stack Overflow and the other open issues in this repo?

yes

Tell us about the problem

I'm testing out webpack following the instructions
here, but when i run

npm run start-ios-bundle
npm run build-ios-bundle

and other commands in the script section of my package.json, I see

Running webpack for ios...
/bin/sh: webpack: command not found
child process exited with code 127

Which platform(s) does your issue occur on?

Both

Please provide the following version numbers that your issue occurs with:

  • CLI: 3.0.3
  • Cross-platform modules: 3.0.1
  • Runtime(s): 3.0.1

    Please tell us how to recreate the issue in as much detail as possible.

run any of the script below
**UPDATE
npm install to fix dependencies

"scripts": {
    "test": "",
    "ns-bundle": "ns-bundle",
    "publish-ios-bundle": "npm run ns-bundle --ios --publish-app",
    "start-android-bundle": "npm run ns-bundle --android --run-app",
    "start-ios-bundle": "npm run ns-bundle --ios --run-app",
    "build-android-bundle": "npm run ns-bundle --android --build-app",
    "build-ios-bundle": "npm run ns-bundle --ios --build-app"
  }

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

npm run start-ios-bundle
npm run build-ios-bundle

All 9 comments

Run npm install before npm run start/build-ios-bundle.

https://github.com/nativescript/nativescript-dev-webpack#usage

I did @sis0k0 and still face the same issue. I've updated the issue to include that,
and this npm run start/build-ios-bundle is wrong, it's not in the script tag.
Did you get this to work for you?

/bin/sh: webpack: command not found

This means that he webpack plugin was not installed. Try cleaning node_modules and installing the deps again:

$ rm -rf node_modules
$ npm install

still the same thing ;-(

Can you post your package.json? Also, are you using npm shrinkwrap or sth like that?

Here is my package.json content.

{
  "name": "projectx",
  "version": "0.0.1",
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "",
  "nativescript": {
    "id": "org.nativescript.projectx",
    "tns-android": {
      "version": "3.0.1"
    },
    "tns-ios": {
      "version": "3.0.1"
    }
  },
  "scripts": {
    "test": "",
    "ns-bundle": "ns-bundle",
    "publish-ios-bundle": "npm run ns-bundle --ios --publish-app",
    "start-android-bundle": "npm run ns-bundle --android --run-app",
    "start-ios-bundle": "npm run ns-bundle --ios --run-app",
    "build-android-bundle": "npm run ns-bundle --android --build-app",
    "build-ios-bundle": "npm run ns-bundle --ios --build-app"
  },
  "dependencies": {
    "@angular/animations": "~4.1.0",
    "@angular/common": "~4.1.0",
    "@angular/compiler": "~4.1.0",
    "@angular/core": "~4.1.0",
    "@angular/forms": "~4.1.0",
    "@angular/http": "~4.1.0",
    "@angular/platform-browser": "~4.1.0",
    "@angular/router": "~4.1.0",
    "nativescript-angular": "~3.0.0",
    "nativescript-theme-core": "~1.0.2",
    "reflect-metadata": "~0.1.8",
    "rxjs": "~5.3.0",
    "tns-core-modules": "~3.0.0",
    "zone.js": "~0.8.2"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~4.1.0",
    "@ngtools/webpack": "~1.4.0",
    "babel-traverse": "6.25.0",
    "babel-types": "6.25.0",
    "babylon": "6.17.3",
    "copy-webpack-plugin": "~4.0.1",
    "extract-text-webpack-plugin": "~2.1.0",
    "lazy": "1.0.11",
    "nativescript-css-loader": "~0.26.0",
    "nativescript-dev-typescript": "~0.4.0",
    "nativescript-dev-webpack": "^0.6.3",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.0.2",
    "typescript": "~2.3.4",
    "webpack": "~2.6.1",
    "webpack-sources": "~1.0.1"
  },
  "false": {}
}

Looks good. Can you verify that the webpack plugin is installed in node_modules? Also check if there's a file named webpack inside node_modules/.bin

@Robophil can you also specify node and npm versions of your system.

Thanks for all the help @sis0k0.
After running

     npm i --save-dev webpack webpack-sources

It works fine now.

Was this page helpful?
0 / 5 - 0 ratings