I'm taking over an existing project. It contains a package.json and Gruntfile. According to the instructions here I've run
npm install
after installing grunt-cli globally.
However, running grunt results in
$ grunt --env=production
Loading "compass.js" tasks...ERROR
>> Error: Cannot find module 'tmp'
Warning: Task "compass" not found. Use --force to continue.
Aborted due to warnings.
Running with -v gives a traceback:
Loading "compass.js" tasks...ERROR
>> Error: Cannot find module 'tmp'
>> 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.exports.init (/..(path)../node_modules/grunt-contrib-compass/tasks/lib/compass.js:4:13)
>> at Object.module.exports (/..(path)../node_modules/grunt-contrib-compass/tasks/compass.js:12:42)
>> at loadTask (/..(path)../node_modules/grunt/lib/grunt/task.js:325:10)
>> at /..(path)../node_modules/grunt/lib/grunt/task.js:361:7
>> at Array.forEach (native)
>> at loadTasks (/..(path)../node_modules/grunt/lib/grunt/task.js:360:11)
"..(path).." has been inserted by me replacing a long base path, it's the project's root.
After some further investigation, compass.js imports the 'tmp' module
var tmp = require('tmp');
Who / what provides this module?
Removing node_modules (which was under source control, to my suprise) and running
npm cache clean
npm install
solved this problem.
As of npm#5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use npm cache verify instead.
If you want to force clean, try npm cache clean --force after that run npm cache verify
Related
So I installed this theme starter for Wordpress which included gulp + webpack configuration. I am new to gulp and webpack.I am kind of new to gulp and webpack. Once I installed the theme on my wordpress site I follow the instruction which where:
Open the Project directory / in Terminal and install the required Node.js dependencies: gulp, webpack, Sass-Compiler, Autoprefixer, etc.
$ npm install
Run the watch script
$ npm run watch
I learned a little bit of gulp and I trying to putting in practice with this new project but for some reason when I run gulpor gulp watch I get the following error:
throw err;
Error: Cannot find module 'gulp-cli'
Require stack:
- /usr/share/nodejs/gulp/bin/gulp.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
at Function.Module._load (internal/modules/cjs/loader.js:667:27)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/usr/share/nodejs/gulp/bin/gulp.js:3:1)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/usr/share/nodejs/gulp/bin/gulp.js' ]
I am able though to compress all my scss and js by running npm run watch. I am just trying to understand why I am not able to use normal gulp commands in this project?
I've cloned a repo that I'm supposed to be working on.
I then tried running the following commands:
npm install
bower install
As well as: cd to my folder and npm install grunt --save-dev
However, when I run grunt I get the following error:
Loading "Gruntfile.js" tasks...ERROR
>> Error: Cannot find module 'load-grunt-config'
Warning: Task "default" not found. Use --force to continue.
Aborted due to warnings.
Execution Time (2018-05-07 11:23:14 UTC+10)
loading tasks 6ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 86%
Total 7ms
This is my Gruntfile.js:
module.exports = function(grunt) {
require('time-grunt')(grunt);
require('load-grunt-config')(grunt, {
jitGrunt: true
});
};
How can I fix this? I am really stuck.
it seems like you don't have 'load-grunt-config' installed (at least I get the exact same error by removing the folder from my node_modules).
run npm install load-grunt-config and/or fix your package.json file by adding "load-grunt-config": "^0.19.2"to the related dependencies.
I've got a project (written in Reason, but compiling to JS) that uses the module https://www.npmjs.com/package/bs-express. When the code is compiled, the require statement for that module looks like this:
var Express = require("bs-express/src/Express.js");
I've definitely added the bs-express dependency to the package.json file inside of my functions folder, and I've verified by hand that the file exists on my dev box.
When I use the command firebase deploy, the deployment of any functions that use that file fails with this error:
Function load error: Code in file index.js can't be loaded.
Did you list all required modules in the package.json dependencies?
Detailed stack trace: Error: Cannot find module 'bs-express/src/Express.js'
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.<anonymous> (/user_code/src/Endpoints.bs.js:10:15)
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)
But, like I said before, firebase serve --only functions on my developer box works just fine.
firebase --version: 3.17.4
Mac OS 10.13.3
Is there any way to get shell access or something on the container being deployed to so that I can see what exists in the node_modules folder there?
Here's what was happening:
bs-express only includes the .re files in its NPM package, not the compiled js artifacts.
firebase deploy does a fresh npm install on the container, it doesn't copy the node_modules folder from the development computer.
bsb -make-world leaves the compiled assets for a library in node_modules inside of the node_modules directory. It doesn't copy them into lib, even if in_source is disabled in bs-config.json
That's why the compiled JS file is missing at runtime.
The possible solutions:
Run bsb on the container and compile the code up there in the postInstall npm hook. (But this doesn't work, because bsb is large and exceeds the container's data size limit of 200MB. Also it takes a loooooooooooooong time to install dependencies during deployment.
Add some bundling step to the javascript code before deploying (Webpack or Rollup). At the moment the way the Bucklescript compiler works has some conflicts with Rollup's standards (https://github.com/BuckleScript/bucklescript/issues/2456#issuecomment-372900255), so Webpack might be a better option.
I am using code ship to run some tests and deploy to galaxy.
Right now the setup works by running meteor from a git checkout. The following is the setup script:
git clone https://github.com/meteor/meteor.git ~/meteor
cd ~/meteor && git reset --hard 365c765 && cd -
export PATH=~/meteor/:$PATH
meteor npm install
Right now I cannot get passed the meteor npm install command without throwing an error. The error is the following:
It's the first time you've run Meteor from a git checkout.
I will download a kit containing all of Meteor's dependencies.
######################################################################## 100.0%
Installed dependency kit v4.2.9 in dev_bundle.
/home/rof/meteor/tools/cli/dev-bundle.js:55
return getDevBundleForRelease(release).then(function (devBundleDir) {
^
TypeError: Cannot read property 'then' of null
at getDevBundleDir (/home/rof/meteor/tools/cli/dev-bundle.js:55:41)
at Object.<anonymous> (/home/rof/meteor/tools/cli/dev-bundle.js:205:18)
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)
at Object.getDevBundle (/home/rof/meteor/tools/cli/dev-bundle-bin-helpers.js:6:10)
at getChildProcess (/home/rof/meteor/tools/cli/dev-bundle-bin-commands.js:28:13)
What do I need to do in order for the meteor install to work on code ship?
There's a script available at https://github.com/codeship/scripts/blob/master/packages/meteor.sh that should take care of the installation.
Include it in your setup steps by adding the following command
curl -sSL https://raw.githubusercontent.com/codeship/scripts/master/packages/meteor.sh | bash -s
If this doesn't work for your project, please open a new issue on the repository or reach out to Codeship Support via https://helpdesk.codeship.com and we'll take a look.
The bundled node.fibers fails to load after deployment to a different server with the following error:
/home/ec2-user/bundle/server/node_modules/fibers/fibers.js:13
throw new Error('`'+ modPath+ '.node` is missing. Try reinstalling `node-fibe
^
Error: `/home/ec2-user/bundle/server/node_modules/fibers/bin/linux-x64-v8-3.11/fibers.node` is missing. Try reinstalling `node-fibers`?
at Object.<anonymous> (/home/ec2-user/bundle/server/node_modules/fibers/fibers.js:13:8)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/home/ec2-user/bundle/server/server.js:3:1)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
Node fibers have to be re-installed after unpacking the bundle. To fix this problem go to the server directory.
$ cd bundle/programs/server
Then un-install fibers
$ npm uninstall fibers
Then install fibers
$ npm install fibers
Then start your application
$ cd ../../
$ PORT=3000 MONGO_URL=mongodb://localhost:27017/myapp node bundle/main.js
You will have to repeat that every time you update the app. This is just the way Meteor uses Node at the moment. Potential long-term fix can be found here: http://meteorhacks.com/how-meteor-uses-node.html
NOTE: On Meteor 0.6.5 and Node 0.10.* this may work slightly differently. You may have to remove fibers manually from bundle/server as well as bundle/programs/server. You can do that with $ rm -R node_modules/fibers. Then you'll have to reinstall fibers from both locations with $ npm install fibers.
I had the same issue with Meteor 1.0.3.2 and Node 0.12.0.
I had to downgrade to Node 0.10.31.
This fixed the issue.
Remember all instructions are in the readme file in the bundle folder.
Mismatched Node Versions
The versions of node MUST match when you do the npm install and when you run the meteor app: node app.js.
Otherwise you can end up with different versions of expected glibc folders...
To see if you have this problem:
note the runtime error you are seeing. For example, in my case:
Try running this to fix the issue: /usr/bin/node <bundle location>/bundle/programs/server/node_modules/fibers/build
Cannot find module '<bundle location>/bundle/programs/server/node_modules/fibers/bin/linux-x64-83-libc/fibers`
The fix instructions referred to /usr/bin/node even though I was managing my node version via nvm.
The executable was looking for fibers in the linux-x64-83-libc folder.
navigate to bundle/programs/server/node_modules/fibers/bin & examine your glibc subfolders. In my case: linux-x64-57-glibc & linux-x64-64-glibc
My executable is looking for linux-x64-83-libc & it does not exist.
Notes
In my case I was using nvm to manage my node versions. But as I could see in the fix instructions, my executable was using /usr/bin/node and not the nvm version I was expecting.
Fix
I removed the /usr/bin/node version via sudo apt-get remove nodejs and all was good. Everything started using the nvm version.