Cannot find module: Ember-template-compiler after upgrading to 2.12.1 - node.js

After upgrading to Ember cli 2.12.1 I receive the following error, when trying to serve ember.
Cannot find module 'C:\Users\assaue\web\client\bower_components\ember\ember-template-compiler'
Error: Cannot find module 'C:\Users\assaue\web\client\bower_components\ember\ember-template-compiler'
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 Class.htmlbarsOptions (C:\Users\assaue\web\client\node_modules\emberx-file-input\node_modules\ember-cli-htmlbars\ember-addon-main.js:72:25)
at Object.toTree (C:\Users\assaue\web\client\node_modules\emberx-file-input\node_modules\ember-cli-htmlbars\ember-addon-main.js:31:43)
at C:\Users\assaue\web\client\node_modules\ember-cli-preprocess-registry\preprocessors.js:180:26
at Array.forEach (native)
at processPlugins (C:\Users\assaue\web\client\node_modules\ember-cli-preprocess-registry\preprocessors.js:178:11)
at module.exports.preprocessTemplates (C:\Users\assaue\web\client\node_modules\ember-cli-preprocess-registry\preprocessors.js:161:10)

Try updating below in package.json
"ember-cli-htmlbars-inline-precompile": "^0.3.6"
Maybe any one of your addons might expect ember to be installed through bower.

I think some of your addon listed in package.json requires ember js to be in bower directory. For my app, the addon was jquery-ui and it was referred as following.
templateCompilerPath = this.project.bowerDirectory + '/ember/ember-template-compiler';
Add
"ember": "2.13.0" ( Latest Version now )
in bower.json
Ember has moved ember package from bower to npm as ember-source, but still it doesn't work as expected because of third party addons
when you don't have ember package in bower.json.
You may get WARNING: Ember.js is now provided by node_moduleember-source, please remove it from bower in terminal when you run your ember app.

I am pretty sure that the problem is in the emberx-file-input module judging from your log.
at Class.htmlbarsOptions (C:\Users\assaue\web\client\node_modules\emberx-file-input\node_modules\ember-cli-htmlbars\ember-addon-main.js:72:25)
Key fragment is \emberx-file-input\node_modules\ember-cli-htmlbars
It doesn't have the correct ember-cli-htmlbars yet and hence it throws the error. Try to find the version of the emberx-file-input which has the correct dependency.

Related

npm run gulp primordials not defined

I'm trying to run npm run gulp and I'm coming up with this primordials is not defined error (I have also added the npm-shrinkwrap.json file as suggested which gets updated after running npm install but it doesn't fix my primordials is not define error):
> gulp-tutorial#1.0.0 gulp
> gulp
fs.js:47
} = primordials;
^
ReferenceError: primordials is not defined
at fs.js:47:5
at req_ (/Applications/MAMP/htdocs/wordpress/wp-content/themes/theming-main/node_modules/natives/index.js:143:24)
at Object.req [as require] (/Applications/MAMP/htdocs/wordpress/wp-content/themes/theming-main/node_modules/natives/index.js:55:10)
at Object.<anonymous> (/Applications/MAMP/htdocs/wordpress/wp-content/themes/theming-main/node_modules/vinyl-fs/node_modules/graceful-fs/fs.js:1:37)
at Module._compile (node:internal/modules/cjs/loader:1095:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1147:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
Node.js v17.0.1
Any suggestions 🙌 ?
Primordials are used by Node.js internal modules and are not accessible to end user scripts. (That's their entire point for existing. Otherwise, you could modify Object.prototype and end up affecting Node.js internals, causing weird crashes and things like that.)
The module that is giving you this error is the natives module. The page for the package says:
This module relies on Node.js's internals and will break at some point. Do not use it, and update to graceful-fs#4.x.
Sounds like it's at that point where it's broken. Use npm ls natives to find out what's using it. (You might need to be in the /Applications/MAMP/htdocs/wordpress/wp-content/themes/theming-main directory when you run the command.) From there, you can try to figure out how to get rid of it.
Another possibility would be to try downgrading to an earlier version of Node.js to see if it works with that version.
The problem was with the versions not matching up. I also had 2 NodeJS installation paths and that was throwing things off.
I uninstalled them all, started from the beginning and used brew to reinstall.
Then checked that the versions were all compatible.
I also had to install node-sass and referred to this compatibility table to get the correct version - https://github.com/sass/node-sass#node-version-support-policy
Now its working and I can get on developing :) As of today Im running Node v17.0.1 Npm v8.1.0 Gulp cli v2.3.0

Facing Issue with Node-Sass within Node Program

From Command Prompt I am able to execute node-sass and convert scss to css
D:\> node-sass test.scss testout.css
works and works correctly.
But...
When I am writing a program in electron ( need to dynamically convert a scss string to css string )
var sass = require('node-sass');
var output = sass.renderSync({
data: Some_SCSS_Content
});
I get an error as below:
(node:96852) UnhandledPromiseRejectionWarning: Error: Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime (80)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.9.4
at module.exports (D:\OASDEV\electron-quick-start\node_modules\node-sass\lib\binding.js:13:13)
at Object.<anonymous> (D:\OASDEV\electron-quick-start\node_modules\node-sass\lib\index.js:14:35)
at Module._compile (internal/modules/cjs/loader.js:967:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1004:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Module._load (internal/modules/cjs/loader.js:727:14)
at Function.Module._load (electron/js2c/asar.js:769:28)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (internal/modules/cjs/helpers.js:74:18)
On searching I found that this might be due to compatibility issues with Node Version.
Ref: Error: Node Sass does not yet support your current environment: Windows 64-bit with false
I have Node 10.18.1 and Node-sass version 4.9.4. They are compatible.
Further on I tried rebuild
npm rebuild node-sass
But that did not work either.
Another I tried changing version of Node-sass , tried 4.14 and 4.12 also.
It really stumps me that why it works from terminal and not in another Node program.
Node-sass doesn't currently support running in Electron. They are both V8 based runtimes, but have different ABI versions from NodeJs. Support might be added in v5 of node-sass

Using nodejs bindings to run native c++ code produces an error

I'm trying to develop an electron app, and I would like to use an npm package that gives vibrancy to a window. This is the package I'm trying to use: https://github.com/sebascontre/windows10-fluently-vibrancy
It uses a visual c++ code to call native windows methods to achieve this vibrancy effect.
I've cloned and I've run the npm install and build as described in the readme and ran the following:
npm install
npm run conf
npm run rebuild
All built successfully and I also see the build\debug artifacts of the c++ build.
When I try to run it (as described in readme):
cd spec\app
electron .
I'm getting the following error message:
Uncaught Exception:
Error: The specified module could not be found.
\\?\F:\Development\windows10-fluently-vibrancy\build\Debug\Vibrancy.node
at process.func [as dlopen] (electron/js2c/asar.js:155:31)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:857:18)
at Object.func [as .node] (electron/js2c/asar.js:155:31)
at Module.load (internal/modules/cjs/loader.js:677:32)
at tryModuleLoad (internal/modules/cjs/loader.js:609:12)
at Function.Module._load (internal/modules/cjs/loader.js:601:3)
at Module.require (internal/modules/cjs/loader.js:715:19)
at require (internal/modules/cjs/helpers.js:14:16)
at bindings (F:\Development\windows10-fluently-vibrancy\node_modules\bindings\bindings.js:112:48)
at Object.<anonymous> (F:\Development\windows10-fluently-vibrancy\index.js:1:35)
According to the message it cannot find the Vibrancy.node file - But I've verified that it exists in the specified location.
Any ideas how to make it run? I have cloned the package to test it since when trying to use the npm itself in my project it gave the same error so I figured I would try the source.
Today I had the exact same issue you're describing here.
I got it to work using electron-rebuild.
From the root of your project run the command: electron-rebuild
Hope this helps you, if not, maybe someone else.

"Foundation - ReferenceError: primordials is not defined when starting a foundation zurb project."

Getting an error when creating a Foundation Zurb project. Tried to solve using the previous suggestions shown for other applications, but none are working.
A post referenced updating elm, and I did so, however, it did not work. Additionally, I reviewed the closed issue for Gulp 3 (i am using gulp 4), but there was not viable fixes (Gulp 3 is broken on Node 12 #2324) or workarounds.
$ foundation new --framework emails
fs.js:27
const { Math, Object } = primordials;
^
ReferenceError: primordials is not defined
at fs.js:27:26
at req_ (/usr/lib/node_modules/foundation-cli/node_modules/natives/index.js:143:24)
at Object.req [as require] (/usr/lib/node_modules/foundation-cli/node_modules/natives/index.js:55:10)
at Object.<anonymous> (/usr/lib/node_modules/foundation-cli/node_modules/graceful-fs/fs.js:1:37)
at Module._compile (internal/modules/cjs/loader.js:759:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
at Module.load (internal/modules/cjs/loader.js:628:32)
at Function.Module._load (internal/modules/cjs/loader.js:555:12)
at Module.require (internal/modules/cjs/loader.js:666:19)
at require (internal/modules/cjs/helpers.js:16:16)
I expect the project to build.
I guess you use NodeJS 12 or newer.
NodeJS 12 (and newer) is (currenctly) not supported by the current CLI. Please use NodeJS 10.
You can switch to NodeJS 10 using nvm, n, nodenv or any other solution for managing NodeJS versions.
primordials is part of the natives package and called in the graceful-fs package as you can see in the stacktrace.
You can try to upgrade the graceful-fs dependency from 3 to 4 but this might not work without other changes.
This is in fs.js of graceful-fs 3:
module.exports = require('natives').require('fs', ['stream'])
From the natives page on npmjs.com:
This package has been deprecated
Author message:
This module relies on Node.js's internals and will break at some point. Do not use it, and update to graceful-fs#4.x.
Also see https://travis-ci.com/DanielRuf/foundation-cli-test/builds/112738932
Compare this to the environment where we have NodeJS 10 (the team of gulp has deleted the 4.0 tag, you can change the line in package.json to reference gulp 4.0.0):
Works for me using the
Manual Setup (node v13.7.0)
To manually set up the template, first download it with Git:
git clone https://github.com/zurb/foundation-emails-template "projectname"
Then open the folder in your command line, and install the needed dependencies:
cd projectname
npm install

Cannot find module connect/utils when installing node+express

I just installed node by cloning the git repo + make && make install. I then installed npm, and used npm to install express (seems like it fetches connect automatically since it's a dependency). However, when trying to start a simple express example i get the error message:
Error: Cannot find module 'connect/utils'
at Function._resolveFilename (module.js:219:11)
at Function._load (module.js:171:25)
at require (module.js:246:19)
at Object.<anonymous> (/home/yngve/local/node/lib/node/.npm/express/1.0.3/package/lib/express/response.js:16:13)
at Module._compile (module.js:302:26)
at Object..js (module.js:308:10)
at Module.load (module.js:234:31)
at Function._load (module.js:201:10)
at require (module.js:246:19)
at Object.<anonymous> (/home/yngve/local/node/lib/node/.npm/express/1.0.3/package/lib/express/index.js:52:1)
Seems someone has the same problem here: http://groups.google.com/group/express-js/browse_thread/thread/287086bd30f79cf1/adbb5c669872e45a
but the conclusion seems to be that one needs connect installed (which I have).
I've checked that I have the following files at least:
/home/yngve/local/node/lib/node/.npm/connect/0.5.8/package/lib/connect/utils.js
/home/yngve/local/node/lib/node/.npm/express/1.0.3/node_modules/connect/connect/utils.js
Anyone have a clue?
Resolved
Added
require.paths.unshift('<path_to_node>/lib/node/connect');
But the newest rev. is fixed, so this shouldn't really be necessary (see answer below).
It seems like it was a bug in express. Installing the latest version, 1.0.5, fixed this problem for me.
It sounds like you don't have your require path including your npm directory. Use require.paths to modify that.
Some more info:
http://jherdman.github.com/2010-04-05/understanding-nodejs-require.html

Resources