I am trying to get my own project written on OSX to build on Ubuntu. It uses several npm packages to build itself. A few of them depend on the npm package js-yaml, which in it's turn depends on a package called 'esprima'. A fresh Ubuntu 14.04 installation gives me the error that this package can not be found:
module.js:340
throw err;
^
Error: Cannot find module 'esprima'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/home/michahell/Documents/projects/pinbored-webkit/node_modules/grunt/node_modules/js-yaml/lib/js-yaml/type/js/function.js:4:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
npm ERR! weird error 8
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
The output tells me that it might have something to do with the legacy binary node, but i should have solved this problem by symlinking node to point to nodejs, using this S.O. post:
nodejs vs node on ubuntu 12.04
So, what is causing npm / node to not be able to find or install this package?
So i have apparently solved this by manually installing the missing node module:
npm install esprima
Apparently, the npm module requiring this esprima module could just find it if it was 'locally' npm installed. If this is intended / deterministic behaviour, that's nice to know :)
Related
I am facing errors with grunt commands for a dojo project with following version of node, npm and grunt-cli
grunt-cli version : 0.1.13
node version : 6.17.1
npm version : 3.10.10
Getting below error when running grunt command after npm install.
PS C:\workspace\ui\test\ui> grunt
module.js:478
throw err;
^
Error: Cannot find module 'has'
at Function.Module._resolveFilename (module.js:476:15)
at Function.Module._load (module.js:424:25)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\6110853\AppData\Roaming\nvm\v6.17.1\node_modules\grunt-cli\node_modules\is-core-module\index.js:3:11)
at Module._compile (module.js:577:32)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
Tried npm install after deleting node_modules.
Tried installing has module before running npm-install
grunt-cli has been installed globally and I see the required module is present in node_module but we still get module not found error.
Can anybody suggest how to resolve this issue ?
This may be caused by incompatible dependencies. I encountered the same error on grunt#1.3.0. Upgrading node/npm tools to newer versions solved the problem in my case:
node#6.3.1 -> node#12.14.0
npm#3.10.3 -> npm#6.13.4
I have installed node-properties-parser globally by running npm install -g node-properties-parser as normal user(vaisakh). Then i ran my test.js file with the command node test.js now it's throwing the error
Error: Cannot find module 'node-properties-parser'
at Function.Module._resolveFilename (module.js:476:15)
at Function.Module._load (module.js:424:25)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/data02/bamboo/test.js:3:12)
at Module._compile (module.js:577:32)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
I ran the above npm install -g node-properties-parser as root user and run the node test.js here it's working fine. But why it's throwing the error while running as normal user?
Thanks. Finally i found the answer, it's working when in run sudo npm install node-properties-parser without the -g option. But still i don't know why the -g option is not woking, in the docs it's given as install globally.
i've been trying to use Yeoman to scaffold a mean app with angular-fullstack-generator, however i've been encountering this weird error i'd never encountered before, i've already tried reinstalling grunt-cli, npm, yo, none of it works, i'm using NVM and Node 4.4.0
I have Python 2.7.11 installed, apparently the 32-bit version, whereas everything else is 64-bit, i don't know if this might be what's causing the problem.
The full description of the error as shown on the console is as follows:
yo angular-fullstack
module.js:327
throw err;
^
Error: Cannot find module 'babel-runtime/helpers/interop-require-default'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (C:\Users\Jonny\AppData\Roaming\npm\node_modules\generator-angular-fullstack\node_modules\babel-register\lib\node.js:3:30)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
So, what am i doing wrong here? Is there anything else i can try to fix the problem?
The error occurs because the babel-runtime module is missing. The babel-runtime module is required for babel to work.
You can fix this by running the command:
npm install --save babel-runtime
I solved it uninstalling and removing babel from node global dependencies and then reinstalling yo and generatog-angular-fullstack.
I had a similar error, it couldn't find gulp-babel, so I installed the module globally.
$ npm install -g --save gulp-babel
And if you're using a mac you may want to try to put sudo in front of the command.
I installed "electron-packager" using npm and executed the command
electron-packager . Johnston --platform=darwin --arch=x64 --version=0.36.0
And then I when I run the "Johnston.app", this error showed up (I didn't even see the main window)
Uncaught Exception: Error: Cannot find module 'electron'
at Function.Module._resolveFilename (module.js:332:15)
at Function.Module._load (module.js:282:25)
at Module.require (module.js:361:17)
at require (module.js:380:17)
at Object. (/Users/David/Github/Johnston/Johnston-darwin-x64/Johnston.app/Contents/Resources/app/main.js:3:18)
at Module._compile (module.js:426:26)
at Object.Module._extensions..js (module.js:444:10)
at Module.load (module.js:351:32)
at Function.Module._load (module.js:306:12)
at Object. (/Users/David/Github/Johnston/Johnston-darwin-x64/Johnston.app/Contents/Resources/atom.asar/browser/lib/init.js:104:10)
Is there any solutions? Thanks!
This likely has something to do with you having a different version of Electron installed on your machine that you are using to build with. In the folder for your app, run electron --version to get the version of electron that you have installed. Then, change the --version=0.36.0 to use whatever version you have installed.
If that doesn't fix it, then you should try rm -rf node_modules && npm install on your project. This will remove you node modules and then reinstall them all. If that doesn't work, please comment here and I will try to help again.
I'm trying to run some NodeJS code using Sharp and i'm getting the following error:
[root#localhost myapp-backend]# node server.js
module.js:340
throw err;
^
Error: Cannot find module './build/Release/sharp'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/root/myapp-backend/node_modules/sharp/index.js:11:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/root/myapp-backend/server.js:277:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:935:3
Any ideas?
Thank you.
Turns out the Debian 8.x distribution I used did not include vips but I did not get an error message. Running
apt-get install libvips
followed by
npm install sharp
resolved the problem and sharp is finally installed and working.
It's probably due to Sharp not getting installed. When I installed it via
npm, there were no errors, but when I went into node_modules/sharp, three were no build files.
You can try to build it by doing
node-gyp rebuild
But, before that, make sure you have Vips installed - that's a lib that Sharp uses. On Mac you'd do
brew install homebrew/science/vips --with-webp --with-graphicsmagick
After you build the Sharp library, you should be good to go.
Check if you don't have build folder on node_modules/sharp, then run:
npm i sharp
it will reinstall and builds sharp. (worked for me)
I was getting the same error in Lambda function for s3 image crop.
I installed the sharp module as below and I was able to crop images using Node.js 14.x version.
npm install --platform=linux --arch=x64 sharp
Please check "node_modules/sharp/build/Release/" folder for "sharp-linux-x64.node"
In my case installing the sharp for specific target version of node.js works, I used below command, but before that remove your existing node_modules folder or remove rm -rf node_modules/sharp
npm install --arch=x64 --platform=linux --target=16x sharp
What worked for me was updating to the latest Node 13 instead of the Node 8 that apt-get provides by default. Answering just for future reference.