Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find '../package.json' on OS X #1647

Closed
alsoicode opened this issue Jan 16, 2019 · 6 comments
Closed

Can't find '../package.json' on OS X #1647

alsoicode opened this issue Jan 16, 2019 · 6 comments

Comments

@alsoicode
Copy link

  • Node Version: 10.15.0
  • Platform: OS X
  • Compiler: Apple LLVM Version 10.0.0
  • Module:
Verbose output (from npm or node-gyp):

When building an Angular Universal project that uses node-sass, node-gyp fails on line 67 of node-gyp.js with:

Module not found: Error: Can't resolve '../package' in '/Users/btaylor/work/angular-apps/[project-name]/node_modules/node-gyp/lib

Paste your log here, between the backticks. It can be:
  - npm --verbose output,
  - or contents of npm-debug.log,
  - or output of node-gyp rebuild --verbose.

ERROR in ./node_modules/node-gyp/lib/node-gyp.js
Module not found: Error: Can't resolve '../../package' in '/Users/btaylor/work/angular-apps/lvs-ui/node_modules/node-gyp/lib'
 @ ./node_modules/node-gyp/lib/node-gyp.js 67:16-40
 @ ./node_modules/node-pre-gyp/lib/util/compile.js
 @ ./node_modules/node-pre-gyp/lib sync ^\.\/.*$
 @ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js
 @ ./node_modules/fsevents/fsevents.js
 @ ./node_modules/chokidar/lib/fsevents-handler.js
 @ ./node_modules/chokidar/index.js
 @ ./node_modules/nunjucks/src/node-loaders.js
 @ ./node_modules/nunjucks/src/loaders.js
 @ ./node_modules/nunjucks/index.js
 @ ./server.ts

This only happens on OS X, currently at 10.14.2. I haven't experienced the same problem on Windows 10.

@thotchkiss
Copy link

I have experienced the same problem on Windows 10. I can modify the statement below (from node-gyp.js) by adding ".json" to the require statement and it works, but obviously breaks npm install.

proto.package = require('../package')

@alsoicode
Copy link
Author

@thotchkiss That at least gets me around the compiler error. Now I just get a slew of warnings instead of errors:

WARNING in ./node_modules/fsevents/fsevents.js 14:13-71
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/chokidar/lib/fsevents-handler.js
 @ ./node_modules/chokidar/index.js
 @ ./node_modules/nunjucks/src/node-loaders.js
 @ ./node_modules/nunjucks/src/loaders.js
 @ ./node_modules/nunjucks/index.js
 @ ./server.ts

WARNING in ./node_modules/fsevents/node_modules/node-pre-gyp/lib/pre-binding.js 20:22-48
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/fsevents/node_modules/node-pre-gyp/lib/node-pre-gyp.js
 @ ./node_modules/fsevents/fsevents.js
 @ ./node_modules/chokidar/lib/fsevents-handler.js
 @ ./node_modules/chokidar/index.js
 @ ./node_modules/nunjucks/src/node-loaders.js
 @ ./node_modules/nunjucks/src/loaders.js
 @ ./node_modules/nunjucks/index.js
 @ ./server.ts

WARNING in ./node_modules/fsevents/node_modules/node-pre-gyp/lib/util/versioning.js 17:20-67
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/fsevents/node_modules/node-pre-gyp/lib/pre-binding.js
 @ ./node_modules/fsevents/node_modules/node-pre-gyp/lib/node-pre-gyp.js
 @ ./node_modules/fsevents/fsevents.js
 @ ./node_modules/chokidar/lib/fsevents-handler.js
 @ ./node_modules/chokidar/index.js
 @ ./node_modules/nunjucks/src/node-loaders.js
 @ ./node_modules/nunjucks/src/loaders.js
 @ ./node_modules/nunjucks/index.js
 @ ./server.ts

WARNING in ./node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js
Module not found: Error: Can't resolve 'npm' in '/Users/btaylor/work/angular-apps/lvs-ui/node_modules/fsevents/node_modules/node-pre-gyp/lib/util'
 @ ./node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js
 @ ./node_modules/fsevents/node_modules/node-pre-gyp/lib sync ^\.\/.*$
 @ ./node_modules/fsevents/node_modules/node-pre-gyp/lib/node-pre-gyp.js
 @ ./node_modules/fsevents/fsevents.js
 @ ./node_modules/chokidar/lib/fsevents-handler.js
 @ ./node_modules/chokidar/index.js
 @ ./node_modules/nunjucks/src/node-loaders.js
 @ ./node_modules/nunjucks/src/loaders.js
 @ ./node_modules/nunjucks/index.js
 @ ./server.ts

WARNING in ./node_modules/fsevents/node_modules/node-pre-gyp/lib/util/nw-pre-gyp/index.html 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
> <!doctype html>
| <html>
| <head>
 @ ./node_modules/fsevents/node_modules/node-pre-gyp/lib sync ^\.\/.*$ ./util/nw-pre-gyp/index.html
 @ ./node_modules/fsevents/node_modules/node-pre-gyp/lib/node-pre-gyp.js
 @ ./node_modules/fsevents/fsevents.js
 @ ./node_modules/chokidar/lib/fsevents-handler.js
 @ ./node_modules/chokidar/index.js
 @ ./node_modules/nunjucks/src/node-loaders.js
 @ ./node_modules/nunjucks/src/loaders.js
 @ ./node_modules/nunjucks/index.js
 @ ./server.ts

WARNING in ./node_modules/node-gyp/lib/Find-VS2017.cs 7:6
Module parse failed: Unexpected token (7:6)
You may need an appropriate loader to handle this file type.
| // Usage:
| // powershell -ExecutionPolicy Unrestricted -Version "2.0" -Command "&{Add-Type -Path Find-VS2017.cs; [VisualStudioConfiguration.Main]::Query()}"
> using System;
| using System.Text;
| using System.Runtime.InteropServices;
 @ ./node_modules/node-gyp/lib sync ^\.\/.*$ ./Find-VS2017.cs
 @ ./node_modules/node-gyp/lib/node-gyp.js
 @ ./node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js
 @ ./node_modules/fsevents/node_modules/node-pre-gyp/lib sync ^\.\/.*$
 @ ./node_modules/fsevents/node_modules/node-pre-gyp/lib/node-pre-gyp.js
 @ ./node_modules/fsevents/fsevents.js
 @ ./node_modules/chokidar/lib/fsevents-handler.js
 @ ./node_modules/chokidar/index.js
 @ ./node_modules/nunjucks/src/node-loaders.js
 @ ./node_modules/nunjucks/src/loaders.js
 @ ./node_modules/nunjucks/index.js
 @ ./server.ts

WARNING in ./node_modules/@angular/core/fesm5/core.js 18261:15-36
System.import() is deprecated and will be removed soon. Use import() instead.
For more info visit https://webpack.js.org/guides/code-splitting/
 @ ./server.ts 5:0-47 14:0-14

WARNING in ./node_modules/@angular/core/fesm5/core.js 18273:15-102
System.import() is deprecated and will be removed soon. Use import() instead.
For more info visit https://webpack.js.org/guides/code-splitting/
 @ ./server.ts 5:0-47 14:0-14

@rvagg
Copy link
Member

rvagg commented Jun 20, 2019

Are you running this with node or some other executable, it looks like TypeScript is involved here and that might be your culprit, interfering with the extensions mechanism used to load .json files.

I'm going to submit a PR to make an explicit .json in that require but I really don't think this is node-gyp's problem, you should report it to TypeScript or whoever's runtime you're using to get to node.

@rvagg rvagg closed this as completed Jun 20, 2019
@alsoicode
Copy link
Author

Yes, this is when transpiling an Angular project using node-sass

@rvagg
Copy link
Member

rvagg commented Jun 21, 2019

This isn't the first time I've seen this, I think that some tools that wrap node are messing with the require extensions. I've put in #1787 to make it explicit, that will hopefully get rolled out soon.

@alsoicode
Copy link
Author

Awesome. Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants