Error: Cannot find module ‘../package.json’

webpack

module.js:471
throw err;
^

Error: Cannot find module ‘../package.json’
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (/Users/vinyuan/code/uculture/webpack-demo3/node_modules/.bin/webpack:17:22)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)

npm ERR! Darwin 16.5.0
npm ERR! argv “/usr/local/bin/node” “/usr/local/bin/npm” “run” “build”
npm ERR! node v6.11.2
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! webpack-demo2@1.0.0 build: webpack
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webpack-demo2@1.0.0 build script ‘webpack’.
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 webpack-demo2 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs webpack-demo2
npm ERR! Or if that isn’t available, you can get their info via:
npm ERR! npm owner ls webpack-demo2
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /Users/vinyuan/code/uculture/webpack-demo3/npm-debug.log

Do you want to request a feature or report a bug?

What is the current behavior?

If the current behavior is a bug, please provide the steps to reproduce.

What is the expected behavior?

If this is a feature request, what is motivation or use case for changing the behavior?

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.

Author: Fantashit

4 thoughts on “Error: Cannot find module ‘../package.json’

  1. hello @Vin-Yuan I am suffering from same issue can you please help.
    I went through your solution but in my case there is no comma issue. Please help

Comments are closed.

Error: Cannot find module ‘package.json’

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
    Mac OS X 10.11.5 (El Capitan)
  2. Versions. Please run ng --version. If there’s nothing outputted, please run
    in a Terminal: node --version and paste the result here:
    angular-cli: 1.0.0-beta.11-webpack.8
    node: 6.5.0
    os: darwin x64
  3. Repro steps. Was this an app that wasn’t created using the CLI? What change did you
    do on your code? etc.
    clone from repository
    npm install --save-dev angular-cli@webpack
    ng version
  4. The log given by the failure. Normally this include a stack trace and some
    more information.
Cannot find module 'package.json'
Error: Cannot find module 'package.json'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at AddonDiscovery.discoverAtPath (/Users/thomasknobloch/workspace/OXEWbm2/wbm/node_modules/angular-cli/lib/models/addon-discovery.js:205:20)
    at AddonDiscovery.<anonymous> (/Users/thomasknobloch/workspace/OXEWbm2/wbm/node_modules/angular-cli/lib/models/addon-discovery.js:114:26)
    at Array.map (native)
    at AddonDiscovery.discoverFromDependencies (/Users/thomasknobloch/workspace/OXEWbm2/wbm/node_modules/angular-cli/lib/models/addon-discovery.js:109:68)
    at AddonDiscovery.discoverProjectAddons (/Users/thomasknobloch/workspace/OXEWbm2/wbm/node_modules/angular-cli/lib/models/addon-discovery.js:48:29)
    at Project.discoverAddons (/Users/thomasknobloch/workspace/OXEWbm2/wbm/node_modules/angular-cli/lib/models/project.js:353:40)
  1. Mention any other details that might be useful.
    ng version works fine outside of my project (using the global installation of angular-cli).

Author: Fantashit

5 thoughts on “Error: Cannot find module ‘package.json’

  1. I’m having this same problem on beta 18.

    Cannot find module 'package.json'
    Error: Cannot find module 'package.json'
        at Function.Module._resolveFilename (module.js:469:15)
        at Function.Module._load (module.js:417:25)
        at Module.require (module.js:497:17)
        at require (internal/module.js:20:19)
        at AddonDiscovery.discoverAtPath (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/models/addon-discovery.js:205:20)
        at AddonDiscovery.<anonymous> (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/models/addon-discovery.js:114:26)
        at Array.map (native)
        at AddonDiscovery.discoverFromDependencies (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/models/addon-discovery.js:109:68)
        at AddonDiscovery.discoverProjectAddons (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/models/addon-discovery.js:48:29)
        at Project.discoverAddons (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/models/project.js:353:40)
        at Project.initializeAddons (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/models/project.js:372:8)
        at Project.eachAddonCommand (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/models/project.js:425:10)
        at module.exports (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/cli/lookup-command.js:33:13)
        at CLI.<anonymous> (/Users/ewbutterfield/vs/pct-service/node_modules/angular-cli/lib/cli/cli.js:34:26)
        at tryCatch (/Users/ewbutterfield/vs/pct-service/node_modules/rsvp/dist/rsvp.js:538:12)
        at invokeCallback (/Users/ewbutterfield/vs/pct-service/node_modules/rsvp/dist/rsvp.js:553:13)
        at publish (/Users/ewbutterfield/vs/pct-service/node_modules/rsvp/dist/rsvp.js:521:7)
        at flush (/Users/ewbutterfield/vs/pct-service/node_modules/rsvp/dist/rsvp.js:2373:5)
        at _combinedTickCallback (internal/process/next_tick.js:67:7)
        at process._tickCallback (internal/process/next_tick.js:98:9)
    

    angular-cli: 1.0.0-beta.18
    node: v6.9.1
    npm: 3.10.8

  2. Try
    ‘Npm install –save http’
    It will add “http” on version 0.0.0
    This reliably reproduces the problem
    Tried 3 times, and that is the error.

    I can send a video if you want.

  3. Just an FYI for anyone else dealing with this issue. I received a similar error message when I would run any angular cli commands (ng serve, ng version etc.) saying Error: Cannot find module 'package.json. I found out that the issue was caused by using a bad npm package (crypto), although I’m not entirely sure why that would have caused the error. When I removed that package from my package.json file, all the angular cli commands worked perfectly. I’m now using bcrypt instead.

  4. After much reading and analysis, the crypto package cause ember-cli to panic. Just remove it npm uninstall crypto –save

Comments are closed.